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
- /
- Plot multiple groups of boxes with decile lines

- 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

06-05-2013 12:35 PM

There does not seem to be a straightforward way to plot multiple box/bar groups with bars separated by decile lines.

I have a dataset with several Measures and deciles for each measure. Here's a simulated dataset:

data d;

do Measure=1 to 5;

do i=0 to 10;

DecileVal = ranuni(0);

output;

end; end;

drop i;

proc rank data=d out=d;

by Measure;

var DecileVal;

ranks Decile;

proc sort data=d; by Measure Decile;

run;

So far the closest I get is this:

proc sgplot data=d;

scatter x=Measure y=DecileVal / markerattrs=(symbol=plus);

run;

Still need:

- Change pluses into horizontal lines

- To add vertical boxes that start at a Min value and end at Max.

Can something like this be done in SGPlot? I need to overlay odds ratios with CI over the bars?

Appreciate any help or pointers.

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

Posted in reply to Haris

06-05-2013 12:59 PM

Here's another SGPLOT routine that gives me something similar to what I am looking for but with estimated rather than literal percentiles, 50th, 25th, and 75th percentiles and whiskers at 0 and 100.

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

Posted in reply to Haris

06-05-2013 01:52 PM

Maybe not with SGPlot but you may find something at http://support.sas.com/sassamples/graphgallery/PROC_SGRENDER_Graph_Template_Language__GTL_.html that looks close to what you want. There are links to code to create each of the examples.

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

Posted in reply to ballardw

06-05-2013 03:58 PM

Thanks for the suggestion, Ballardw. Nothing there that looks like what I want but a good resource. Also, have done very limited amount of programming in TEMPLATE. Useful skill but a steep learning curve.

I ended up transposing the Tall file into a wide one and using the following code:

proc sgplot data=df noautolegend;

highlow x=Outcome low=D1 high=D11 /type=bar;

highlow x=Outcome low=D2 high=D10 /type=bar;

highlow x=Outcome low=D3 high=D9 /type=bar;

highlow x=Outcome low=D4 high=D8 /type=bar;

highlow x=Outcome low=D5 high=D7 /type=bar;

highlow x=Outcome low=D6 high=D6 /type=bar;

scatter x=Outcome y=OR / markerattrs=(color=black symbol=DiamondFilled size=15)

yerrorlower=Lower yerrorupper=Upper errorbarattrs=(color=black thickness=2);

xaxis labelattrs=(weight=bold size=14);

yaxis label='Odds Ratio (95% CI)' labelattrs=(weight=bold size=14);

run;

Any feedback or suggestions for improvement is greatly appreciated.

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

Posted in reply to Haris

06-09-2013 07:02 AM

You can overlay SCATTERPLOT on BOXPLOT using GTL.

And yes, you can use a combination of HIGHLOW plots to simulate a box plot as I discuss in this blog post. http://blogs.sas.com/content/graphicallyspeaking/2013/03/24/custom-box-plots/