- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sort data=sreportlabels;
by sex;
run;