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:
do Measure=1 to 5;
do i=0 to 10;
DecileVal = ranuni(0);
proc rank data=d out=d;
proc sort data=d; by Measure Decile;
So far the closest I get is this:
proc sgplot data=d;
scatter x=Measure y=DecileVal / markerattrs=(symbol=plus);
- 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.
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.
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);
Any feedback or suggestions for improvement is greatly appreciated.
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/
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.