BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mmohotsi
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
mmohotsi
Quartz | Level 8
This solution is used in the by group scenario. In the data set I have categories are kept in the group = option

View solution in original post

5 REPLIES 5
mmohotsi
Quartz | Level 8
This solution is used in the by group scenario. In the data set I have categories are kept in the group = option
PaigeMiller
Diamond | Level 26

In the link, the colors are assigned to the values of the variable in the GROUP= option. Works with or without a BY variable.

--
Paige Miller
mmohotsi
Quartz | Level 8

Thanks PaigeMiller

 

This is the solution to my challenge

 

Regards

mmohotsi

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 252 views
  • 0 likes
  • 2 in conversation