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;
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.
Thank you for your reply. I did try switching the variable and the figure didn't look as expected. Please see the attached image.
@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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.