Data visualization with SAS programming

making color assignments permanent in stacked graphics

Reply
New Contributor ash
New Contributor
Posts: 4

making color assignments permanent in stacked graphics

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;
SAS Employee
Posts: 963

Re: making color assignments permanent in stacked graphics

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).
Post a Question
Discussion Stats
  • 1 reply
  • 90 views
  • 0 likes
  • 2 in conversation