Hi everyone,
I am creating graphics depicting trends of catastrophic sport injuries in all U.S. states. I want to make sure my colors are consistent for each scenario and state.
In one of my vbar graphs, I am showing injuries by sport and sex. I want to make sure athletesex will be blue for male and red for female. Additionally, I want to make sure that the blue bar showing males appears on the left side of the red. Right now, I think SAS is automatically putting the one with a higher value to the left, and I do not want that. My code is below.
proc sgplot data=sreportlabels;
title "Frequency of Catastrophic Sport Injuries by Sport and Sex in Alabama (2013-2022)";
vbar injurysport / group=athletesex groupdisplay=Cluster;
xaxis label = "Sport";
yaxis label = "Frequency" values = (0 to 20 by 5);
where state = "Alabama";
run;
Thank you for the help!
You probably want to use the GROUPORDER=DESCENDING option of the VBAR statement to force males to come first.
To force the colors to be something specific and unchanging, you can use a discrete attribute map.
This is the reply from @PaigeMiller before this was moved to the Graphics Programming community.
You need to create and use a discrete attribute map.
Example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm |
-------------------------------------------------------------------------
Four tips to remember when you contact SAS Technical Support
Tricks for SAS Visual Analytics Report Builders
SAS Visual Analytics Learning Center
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 16. 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.