BookmarkSubscribeRSS Feed
tania_w
Calcite | Level 5

I know that there are a lot of support materials on Proc GCHART but I have not been able to apply them to the type of chart I would like to produce.

I have produced a grouped bar chart which shows a 3D chart with blocks for each currency in different colors. There are two blocks for each currency on the x axis, one for "Company A" and one for "Company B" (var=activity_typ).

Is there any way that I can retain the colors assigned to the MIDPOINT variable (curr_group) but assign a lighter transparency or some sort of cross-hatch pattern to the different groups of the GROUP variable (activity_typ)? So that, for example, the bar for USD would be light red for Company A and dark red for Company B?

My code is as follows:

PROC GCHART DATA=WORK.mydata;

  BLOCK  curr_group  /

  SUMVAR=amount

  GROUP=activity_typ

  SHAPE=BLOCK

  TYPE=SUM

/* Anno=anno*/

  NOLEGEND

  COUTLINE=BLACK

  RAXIS=AXIS1

  MAXIS=AXIS2

  GAXIS=AXIS3

PATTERNID=MIDPOINT

;

RUN;

3 REPLIES 3
ballardw
Super User

Classic Gchart behavior is basically that the first level encountered is assigned the appearance values of the first Pattern statement, the 2nd the second pattern and so on. Getting specific colors/ shade with any consistency means having all levels of variables represented in each combination of categories and sorting and getting Pattern definitions to align. Add a new category- start over.

This may require have a missing value for the sumvar (amount) for group variable (activity_typ) if every level of the block variable (curr_group) doesn't have all levels of the group variable.

If you are using 9.4 there are options with the SG procedures to assign color attributes to levels of variables so they are consistent regardless of sort order or value presence in the data,

Jay54
Meteorite | Level 14

If I am understanding your requirement, you want the bars to be colored by midpoint (along x axis, say 'A', 'B', 'C' and so on colored say Blue, Red, Green.  For each categoryyou have 2 group levels, say 'X' and 'Y'.  Normally, in such a case, the standard procedure is to assign colors to the groups, and not to each category.  The categories are labeled on the x-axis anyway, so using an additional color for the category is considered unnecessary and potentially confusing.   From an "Effective Graphics" perspective this is not recommended.

Having said that, it is possible to do something like this using SG or GTL. One way is described by Ballardw.  Another would be to overlay two VBAR statements one each for the two groups, shifted left and right using DiscreteOffset, with narrower bars.  This will need restructuring your data from group to multi-column (easily done).  The Bars can be grouped by category so each midpoint will get different color.  Now, for the 2nd VBAR, you can set a transparency value to make it look lighter.

tania_w
Calcite | Level 5

Thank you Sanjay and ballardw. I may need to re-think whether additional shading/colours will add clarity, but your suggestions have given me some great solutions to work with!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1199 views
  • 0 likes
  • 3 in conversation