Hi SAS users,
I have constructed a boxplot graph with a lattice layout and a break at a specific location of the Y AXES. I was trying to add the n for the comparison groups to the bottom row by using innermargins. However when I add the innermargin the Y axis break changes location and disrupt the graph. What can I do to preserve the break at the right spot?
proc template; define statgraph BrokenAxis; begingraph; layout lattice / rows=2 rowweights= (.5 .5)columns=1; rowaxes; rowaxis / griddisplay= on display = (ticks tickvalues line); rowaxis / griddisplay= on display = (ticks tickvalues line); endrowaxes; entrytitle 'Unadjusted'; /*define row 1 */ layout overlay / xaxisopts= (display= (line)) yaxisopts=(display=(ticks tickvalues label)label="Cost ($)" griddisplay=on linearopts=(includeranges=(min-120000 330000-max) tickvaluelist=(20000 40000 60000 80000 100000 330000))); boxplot x=&GRP y= ACT_TOTAL_COSTad / meanattrs = (SYMBOL = DIAMOND weight=bold ) group=&XVAR groupdisplay=cluster medianattrs= (thickness = 2); endlayout; /*define row 2 */ layout overlay /xaxisopts=( display=(ticks tickvalues line) type=discrete discreteopts =(tickvaluefitpolicy=extractalways ) ) yaxisopts=(display=(ticks tickvalues label)label="poLOS (days)" griddisplay=on linearopts=(includeranges=(min-30 95-max) tickvaluelist=(5 10 15 20 25 95))); boxplot x= &GRP y= postopLOS / meanattrs = (SYMBOL = DIAMOND weight=bold ) group= &XVAR groupdisplay=cluster medianattrs= (thickness = 2)name ="L" ; discretelegend "L" /border=true AUTOALIGN = (BOTTOM) LOCATION=OUTSIDE ; innermargin / align=bottom separator=true; axistable x =&GRP value = np /class=&XVAR colorgroup=&XVAR valueattrs=(size=7) labelattrs=(size=7); endinnermargin; endlayout; endlayout; endgraph; end; run; proc sgrender data= combined1 template= BrokenAxis; format DM DM. ACT_TOTAL_COSTad cost_D comma7.; run;
Since we don't have your data, try these two things and see if it makes any difference:
1. Remove the ROWAXES block. Since your ROWDATARANGE is DATA by default, they should have no effect -- but let's see.
2. On your AXISTABLE, set CLASSDISPLAY=CLUSTER, which will position your axis table values under the box, taking up less vertical space.
Please post back with your results.
Thank you for your suggestions. The result is still messy though: not all the N are displayed, only the first row (blue). The break was raised a little but the outliers shown above the break at 95, in reality should be below it. Any other idea?
I am sorry I just realized that I did not implement your suggestion to include CLASSDISPLAY=CLUSTER.
For some reason the command is ignored and I cannot manage to overcome the below message:
CLASSDISPLAY=CLUSTER ------------ 1 WARNING 1-322: Assuming the symbol CLASS was misspelled as CLASSDISPLAY.
We did some testing here, and found this particular issue was fixed at SAS 9.4m3 (maintenance 3). You are currently running maintenance 1. Also, the CLASSDISPLAY option I suggested was added in maintenance 2. Do you have access to a maintenance 3 or greater installation?
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.