turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- sgplot and dot procedure

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-16-2010 03:59 PM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to steve_f

08-16-2010 04:44 PM

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]

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]

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to DanH_sas

08-17-2010 09:16 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to steve_f

08-17-2010 10:56 AM

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

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

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