BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am creating a boxplot of ethnicity stratified by gender. I want a box for males and one for females right next to eachother representing each ethnicity, is there a way to make the boxes side by side and not overlapping?


This is my graph code:
goptions reset = all;
goptions ftext='swiss' htext=12pt xpixels=1800 ypixels=1500;
symbol1 interpol=boxt10 cv=black co=black bwidth=15 v=dot width=1 height=1;
symbol2 interpol=boxt10 cv=red co=red bwidth=15 v=dot width=1 height=1;
symbol1 cv=black co=black v=dot width=1 height=1;
symbol2 cv=red co=red v=dot width=1 height=1;
axis1 major=(n=2 H=1) label=(h=30pt 'Gender') width=2 offset=(25pct);
axis2 major=(n=3 H=1) label=(h=30pt 'Ethnicity') width=2 offset=(10pct);
axis3 label= (a=90 r=0 F='swiss' 'Predicted Clearance') order=0 to 160 by 20;
run;

I have specified a seperate color for both men and women and added a legend so that you can tell them apart.
This is my plotting code:

proc gplot data= cl2;
title height=36pt 'Boxplot of Predicted V3 by Ethnicity Stratified by Gender';
footnote height=28pt 'Box-25th to 75th
Error Bars-10th to 90th';
plot Predicted_cl*ethnicity= gender/
haxis=axis2
vaxis=axis5;
run;
quit;

my result is a boxplot by ethnicity with sperate color boxes for males and females overlapping one another.

Is there a way that I can make males and females side by side so that the graph is easier to read?

Thanks!
1 REPLY 1
Doc_Duke
Rhodochrosite | Level 12
Check the documentation for PROC BOXPLOT. It think it has the option you want.

Otherwise, you could do it in PROC GPLOT by doing a separate plot for each level of ethnicity and then using GREPLAY to re-assemble the pieces (clumsy, but it might get you to the answer if you need other features of GPLOT).

Doc Muhlbaier

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1049 views
  • 0 likes
  • 2 in conversation