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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 783 views
  • 0 likes
  • 2 in conversation