BookmarkSubscribeRSS Feed
steve_f
Calcite | Level 5
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?
3 REPLIES 3
DanH_sas
SAS Super FREQ
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]
steve_f
Calcite | Level 5
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
GraphGuy
Meteorite | Level 14
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

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1461 views
  • 0 likes
  • 3 in conversation