Data visualization with SAS programming

sgplot and dot procedure

Reply
New Contributor
Posts: 2

sgplot and dot procedure

I am trying to use the sgplot dot procedure to plot a numeric variable against a categorical variable with the dot as the mean and the standard error of the mean as the whisker. I want the y axis to be the numeric variable and the x axis to be the categorical variable but SAS has it the other way. Is there a simple axis statement that I can use to reorient this plot?
SAS Super FREQ
Posts: 889

Re: sgplot and dot procedure

Hey Steve,

There is currently not an orient option for the DOT plot, but you can work around this by pre-summarizing the data yourself and using the SCATTER statement in SGPLOT. Here is an example:

[pre]
proc summary data=sashelp.class nway;
class age;
var height;
output out=meandata mean=mean_height lclm=lower uclm=upper;
run;
[/pre]
[pre]
proc sgplot data=meandata;
xaxis grid;
scatter x=age y=mean_height / yerrorupper=upper yerrorlower=lower
markerattrs=(symbol=circlefilled);
run;
[/pre]
New Contributor
Posts: 2

Re: sgplot and dot procedure

Thanks a lot for your help, Dan,

I also want to calculate the 95% confidence interval around a median for the data. I was using proc boxplot where the notches are the 95% confidence interval for the median, but I don't need the interquartile range and whiskers. Do you know of code to suppress everything but the confidence interval? Alternately, I suppose I could simply used the formula in the help information of 1.58 * IQR * n ^ 1/2 similarly to what you suggested for the means.
Steve
SAS Employee
Posts: 967

Re: sgplot and dot procedure

If you can't get the boxplot you want using 'proc boxplot' or 'proc gplot' (with interpol=box), etc ... here's an example you might can modify to create your own custom 'boxplot' in whatever way you want (using annotate move/draw commands):

http://robslink.com/SAS/democd47/anno_boxplot.htm

http://robslink.com/SAS/democd47/anno_boxplot_info.htm
Ask a Question
Discussion stats
  • 3 replies
  • 157 views
  • 0 likes
  • 3 in conversation