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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.