BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Giampaolo
Obsidian | Level 7

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Absolutely! Go to the link below and click on the "Free Software" button. The web pages will take you through the steps.

 

https://www.sas.com/en_us/software/university-edition.html

 

Thanks!
Dan

View solution in original post

15 REPLIES 15
DanH_sas
SAS Super FREQ

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.


Thanks!

Dan

Giampaolo
Obsidian | Level 7

Hi Dan,

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?

Thank you

Giampaolo

Giampaolo
Obsidian | Level 7

Hi Dan,

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.

 

 

  

DanH_sas
SAS Super FREQ

Which maintenance level? The easiest way to get that information is to run the following code;

 

%put &sysvlong;

 

Thanks!

Dan

Giampaolo
Obsidian | Level 7
10959  %put &sysvlong;
9.04.01M1P120413
DanH_sas
SAS Super FREQ

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?

Giampaolo
Obsidian | Level 7
No I use the version that is made available by the university.
Thanks
DanH_sas
SAS Super FREQ

If you download the latest University Edition, you should be able to do this graph without any problem.

Giampaolo
Obsidian | Level 7
Could you please let me know how to do this? Is there a link?
Thank you!
DanH_sas
SAS Super FREQ

Absolutely! Go to the link below and click on the "Free Software" button. The web pages will take you through the steps.

 

https://www.sas.com/en_us/software/university-edition.html

 

Thanks!
Dan

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 3462 views
  • 0 likes
  • 2 in conversation