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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation