BookmarkSubscribeRSS Feed
DinoPut
Obsidian | Level 7

Hi

 

I am trying to create a boxplot by several groups. But I am having a lot of trouble grouping them and presenting them in the right order. I would really appreciate if someone could help me.

 

I have also attached the output.

I would like 'Yes' and 'No' to be grouped within the groups 'a' 'b' 'c' .....

 

Thanks in advance!

 

Code:

 

proc template;
define statgraph box_template;

begingraph / designwidth=6.5in designheight=4.33in ;

*--------------------------------------------------------------------*
| BOX Plot
*--------------------------------------------------------------------*;

layout overlay / yaxisopts=(label="&ylabel")

xaxisopts=(label="&xlabel");


boxplot x = treat y = aval/ group = &group name="treat" groupdisplay = cluster display=(caps fill mean median OUTLIERS ) outlierattrs=(symbol=circle);

discretelegend "treat" / location=outside halign=center valign=bottom
order=ROWMAJOR across= 2 border=false valueattrs=(size=7pt) displayclipped=true;

endlayout;
endgraph;
end;
run;

3 REPLIES 3
ballardw
Super User

Steps for resolving this:

Which variable's values appeared on the axis?

Which variable's values appeared in the legend as a result of being the Group= variable?

 

Switch the positions of those variables in the code.

DinoPut
Obsidian | Level 7

Thank you for your reply. I did try switching the variable and the figure didn't look as expected. Please see the attached image.

ballardw
Super User

@DinoPut wrote:

Thank you for your reply. I did try switching the variable and the figure didn't look as expected. Please see the attached image.


You changed the code. You should show us the changed code.

And there are two variables that need to change. Your image (which can be posted in line by using the PHOTOS icon in the message menu to navigate to where the output was created instead of making other documents and attaching them) looks like you only switched one and likely have the YESNO variable in two places in your boxplot statement.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 3 replies
  • 1060 views
  • 0 likes
  • 2 in conversation