Good day
I have a data set that changes depending on the attributes in the database. I am trying to draw a stack graph for this data set. The data set is as in the attached files. The program below provides a graph with the following colors to the distinct groups:
White color - Out of commission
Yellow color: sampled not scheduled
Blue color :Recommissioned
How do I keep the colors constant to each of these groups regardless of whether a certain category is available or not in the extracted data set.
The code I used is as follows:
proc sgplot data = data.Data_Raw pctlevel=group noborder ;
styleattrs datacolors=( deepskyblue yellow white ) ;
vbar PIPELINE / stat=pct group = Screen_0001 groupdisplay=stack name='Barcharts'
barwidth=0.5 ;
keylegend 'Barcharts' / TITLEATTRS=(weight=bold family=Helvetica size=5) position=bottom noborder;
yaxis label='% Composition' LABELATTRS=(weight=normal size=12);
xaxis display=(nolabel) valuesrotate=vertical;
title "Graphical representation" justify=right;
run;
Regards
In the link, the colors are assigned to the values of the variable in the GROUP= option. Works with or without a BY variable.
Thanks PaigeMiller
This is the solution to my challenge
Regards
mmohotsi
Please be kind enough to un-mark your comment as a solution (since it is not a solution in any meaningful sense) and mark the link I provided as the solution.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.