Thursday, April 8, 2010

Proc Boxplot




******************************************************
Proc Boxplot code including:
**outplot to CGM file
**axis options to split labels onto two lines
**insetgroup option to include statistics on top
**adjusting size and color of boxes
******************************************************


filename outplot 'Z:\SAS\Boxplot';
goptions reset=ALL
gunit=pct
ftext=hwcgm001
ftitle=hwcgm009
htitle=2
htext=2
noborder
maxcolors=255
dev=cgmof97l
rotate=LANDSCAPE
gsfmode=replace
gsfname=outplot;


axis1 label=none value=(t=1 j=c "Group 1" j=c "4/1/10"
t=2 j=c "Group 2" j=c "4/2/10"
t=3 j=c "Group 3" j=c "4/3/10"
t=4 j=c "Group 4" j=c "4/4/10"
t=5 j=c "Group 5" j=c "4/5/10");


proc boxplot data=boxplotdata;
plot (Var1 Var2)*XVar /cboxes=black boxwidth=10 nohlabel haxis=axis1;
insetgroup n mean (5.1)/ pos=top cfill=yellow;

run;

**This code would produce another boxplot with the Y-axis variable "Var2" as well. **

For Further examples see the following:
1. SAS support examples
2. PDF "Customizing Your Own Box Plot"

No comments:

Post a Comment