SAS- PROC UNIVARIATE > histogram > x axis values - sas

I have a single continuous variable with highly skewed distribution. I have log transformed it for normalization. while creating a histogram of the variable with PROC UNIVARIATE (SAS 9.3), is there a way by which I can plot the transformed variable, but keep the values of original variable on x axis ?
if this topic has been already discussed then, I would really appreciate if someone can provide a link. Thank You.

You could use the SAS Graph Template Language (GTL) to do this. The documentation contains plenty of examples that you should be able to change and modify to your needs. The output from PROC UNIVARIATE is produced by the GTL so you should be able to generate something similar.
Take the output dataset from proc univariate and base the plot off that. You will need to reverse the transformations first.
Documentation for the GTL:
http://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#p1sxw5gidyzrygn1ibkzfmc5c93m.htm

Related

Kruskal-Wallis test vs. ANOVA in SAS with complex survey data?

I am analyzing a temporal trend(yr) of certain chemicals(a b & c).
I use proc sgplot and series statement to draw a plot and found there was a decreasing trend.
Becuase the data is right-skewed, I used the median concentration of each year to draw the plot.
Now I would like to conduct a statistical test on the trend. My data came from the NHANES and need to use the proc survey** to perform analysis. I know I can do an ANOVA test based on proc surveyreg and use ANOVA option in the MODELstatement.
proc suveyreg data=a;
stratum stra;
cluster clus;
weight wt;
model a=yr/anova;
run;
But since the original data is right-skewed, I think maybe it is better to use Kruskal-Wallis test on the original data. But I don't know how to write a code in SAS and I didn't find information in proc survey**-related document.
My plan B is to use the log-transformed data and ANOVA test. But I am not sure if that is an appropriate approach. Can somebody tell me how to get the normality test of the residual in ANOVA while using proc surveyreg? I would also like to know if I can test a b & c in one procedure or I should write multiple procedures with changes in MODEL statement.
Looking forward to your engagement.Thank you!

Producing confidence intervals for sensitivity and specificity in SAS

I am using SAS for producing ROC curves. But the "PROC LOGISTIC" does not give me the confidence-interval for sensitivity and specificity.
Does any one know if there is an option in order to produce the lower and upper band for sensitivity and specificity ?
If it is not the case, does anyone know another method ?
Thk an lot,
when I use basic stats, I use proc freq for associations.
proc freq data=tempds noprint;
tables variable1*std_variable2 / chisq measures;
output out=outds pchi n OR FISHER;
run;
The output dataset "outds" now contains RROR(OR), L_RROR(Lower CI), U_RROR(Upper CI). Is this what you are looking for?
If proc logistic doesn't directly support this, you could try bootstrapping - produce many ROC plots for random samples of your data (e.g. using proc surveyselect) and then calculate the p5 and p95 points for each x and y value in the plot using proc summary. This should give a good approximation provided that you use a large enough number of samples.

Replace missing data in SAS with prediction: Regression Imputation

I have a SAS data set with missing data in multiple columns. I would like replace the missing data with a prediction based on the other data in the data set. Here a link that describes the method but doesn't show me how to do it. How do I replace the missing values with a prediction?
EDIT:
The method I had in mind was just using Proc Reg then apply the coefficents to the missing data to generate the estimate. Does this answer your question?
PROC STDIZE, PROC EXPAND, and PROC MI are all capable of performing different kinds of imputations on your data depending on exactly how you want do determine the 'prediction'.
For simple things like replacing with the mean, PROC STDIZE is the way to go. PROC MI is the most advanced - it performs multiple imputation. PROC EXPAND is appropriate if you have time-series data, as it will try to work out what the correct value is for that point in the time series.
If you have missing data in multiple columns you'll require multiple regressions. This probably isn't a good way to do this, but to answer the question - what you're requesting is called scoring a dataset and you can use PROC SCORE.
An alternative method is in your regression procedure request an OUTPUT data set that contains the predicted values for that regression.
output out=predicted1 p=pred_var_missing;
As a matter of methodology, I recommend #Joe's method instead.
Adding to #Joe 's answer, if you tell us why you want to do this imputation, we can provide better advice. I wrote a blog post called How to Ask a Statistics Question that may help.
However, often, single imputation is a bad method. More particularly, if you are going to do further analysis on this data (with the imputed values) then single imputation will underestimate the variability of the data and give wrong results.
PROC MI is usually a better approach.

how to find outliers in sas with proc means?

is there a way to detect an outlier from proc means while calculating min max Q1 and Q3?
the box plot procedure is not working on my SAS and I am trying to perform a boxplt in excel with the values from SAS.
Assuming you have a specific definition for what an outlier is, PROC UNIVARIATE can calculate the value that appears at that percentile using the PCTLPTS keyword on the OUTPUT statement. It also will identify extreme observations individually, so you can see the top few observations (if you have few enough observations that the number of extremes is likely to be <= 5).
The paper A SAS Application to Identify and Evaluate Outliers goes over a few of the ways you can look at outliers, including box plots and PROC UNIVARIATE, and includes some regression-based approaches as well.
If you want a 'standard boxplot' use the outbox= option in SAS to create the standard data set used for a box plot.
proc boxplot data=sashelp.class;
plot age*sex / outbox = xyz;
run;

Remove overlapping X-axis labels on a barchart

Short of using annotations, I have been unable to find a reasonable way to prevent my x-axis labels from overlapping when using a barchartparm in SAS. From the documentation, they clearly state that barcharts use a discrete axis and the other axis types such as time are not permissible for them. Although conceptually this makes sense it seems like an 'unnecessary' limitation to enforce as it leaves no control over the x-axis labeling as every discrete label will be printed.
Sample data:
data test;
format rpt_date date9.;
do rpt_date=date()-90 to date();
root = round(ranuni(1) *100,1);
output;
end;
run;
Define the chart template:
proc template;
define statgraph giddyup;
begingraph;
layout overlay;
barchartparm x=rpt_date y=root ;
endlayout;
endgraph;
end;
run;
Create the chart:
proc sgrender data=test template=giddyup;
run;
Result:
I tried to be duct-tape it and create a custom format for the x-axis that would 'blank-out' many of the values, and although the chart was produced, it stacked all the blanks together (??) and also produced a warning.
I've also tried using the alternate x2axisopts and setting the axis to secondary with no luck.
If I used a series chart I would be able to control the axis fine, but in my case the data is much easier to interpret as a barchart. Perhaps they needed to add additional options to the xaxisopts for barcharts.
The most frustrating thing here is that it's something that you can do in excel in 2 seconds, and to me seems like it would be a very common chart in excel, that is not easily reproducible in SAS!
EDIT: I also don't want to use proc gchart .
Ok now I feel silly. Turns out that histograms will achieve the same result nicely:
histogramparm x=rpt_date y=root ;
Still a valuable question I guess as I spent a lot of time googling for answers and could not find a solution.
Good thing I didn't want it horizontal...