BookmarkSubscribeRSS Feed
ash
Fluorite | Level 6 ash
Fluorite | Level 6
I'm using pattern assignments in gchart for observations in 6 categories - I have patterns 1-6. I'm also creating multiple charts at once using the "by" statement (one chart for each group). If a group does not have an observation in a category, then SAS reassigns what category a pattern refers to, and thus changes the color dynamic for the whole graph. So, I'm making 50 graphs (one for each state), and I'm getting ~50 different color schemes for categories. Is there a way to assign the colors to the categories, non-dynamically?

Code:

pattern1 v=solid c=yellow;
pattern2 v=solid c=stlg;
pattern3 v=solid c=steel;
pattern4 v=solid c=LIPB;
pattern5 v=solid c=orange;
pattern6 v=solid c=lightgray;


proc gbarline data=six;
by state;
bar graphcode/ sumvar= pcr_count
subgroup = subtype
clipref
width=5
FRAME MIDPOINTS=5 TO 58 BY 1
type=sum
coutline=black
raxis=axis1
maxis=axis2
legend=legend1;

plot / sumvar=flupos type=mean
axis=axis3
legend=legend2;

run;quit;
1 REPLY 1
GraphGuy
Meteorite | Level 14
It's a bit awkward/kludgy, but you're probably going to have to add some 'missing' values to your data ... each of the 50 states will have to have each of the 6 subtypes (with a sas 'missing' value for the pcr_count). -- There might be another way, but this is the technique I usually use.

This should work ok, since you're doing a type=sum bar chart (whereas if you were doing a frequency count bar chart, you might have to be a little trickier).
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
  • 1 reply
  • 1238 views
  • 0 likes
  • 2 in conversation