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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 728 views
  • 0 likes
  • 2 in conversation