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.
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.
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);
run;
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/
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.