BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Does anyone know how to assign specific colors to values of the Subgroup Variable in Proc gchart when using by-groups?

IE: I'm producing Charts by Month and the Bars have a subgroup "Type" = Light, Medium, Heavy, etc.

It seems like Proc gchart assigns the colors for the Subgroup based on the First, Second, Third, .... "Type" it encounters for Each by-group. The effect isSub-group categories can be coloured differently depending on the Month.


What I want is for each Type Value to have the same color in every chart.

Thanks.
2 REPLIES 2
Bill
Quartz | Level 8
I think this document will help you get started - http://support.sas.com/kb/24/874.html
deleted_user
Not applicable
Thanks for the response Bill.

The Code structure of your solution has a similar form to a Mechanism I use to Produce separate PDFs for by-groups (another feature I wish SAS would implement) so I should be able to fumble through it.

In this case I have worked out a Partial Solution to my problem that Pre-processes the Data to determine all the possible Variable combinations for the By-group, Vbar, & Sub-group and creates Dummy observations so that Every Sub-group is reflected in every (by-group * Vbar combination). The Dummy Observations have "Zero" for the Quantity I intend to graph.

That way, when Proc Gchart encounters Every Sub-group for Every chart it generates in the By-group & Every Column on the x-axis in the same order.

Thus: The Colours assigned to the Sub-groups in the First round are the same for every Graph.

The only drawback to my solution is That Every Sub-group for Every chart appears in the Legend. Not a huge problem as it is a relatively small number plus it reminds the User of the categories to expect in other graphs. I say close enough.

Now I plan to use the provided document to improve my fix so that I can Specify the colours to use, which would be sweet.

At a glance It appears that the Fix in the Link requires that the User have Prior Knowledge of the Number and Names of the Sub-groups. Not a problemin this case, but I always prefer Robust techniques to Hard-coding.


SAS - If you are listening this would be a welcome Feature for a new release.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 646 views
  • 0 likes
  • 2 in conversation