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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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