Click here to see the SAS code.
Click here to see the example.


See my blog for more information about this graph!

This is a SAS/Graph imitation/enhancement of:

Here are some of the "tricks" put to use in this example:

I create a user-defined format for the numeric days 1-12,
and associate with them the text values of the gift for that day.
The numeric days are easier to deal with (I can programmatically
loop through them, and the things in the bar chart are ordered
numerically ... but then I can have the labels print as the 
text values).

To create the data, I programmatically loop through from 
13dec-24dec, and each time through I increment the "days_of_christmas"
variable, and go through a subloop from 1-days_of_christmas
to generate an obsn for each gift.

I use gchart vbar to create the bar chart, and I "subgroup" 
so each bar has a separate colored segment for each gift
(with the height of the segment representing the quantity 
of that gift on that day).

I use the v9.2 ods graph styles to generate the colors for the
bar segments automatically (rather than hard-coding pattern

I use the date5. format to print just the numeric day-of-month
at the bottom of the bars (rather than 24DEC2009, etc).

I use a legend statement to print the legend to the right of the graph,
and I hard-code the order of the legend so it will be in the same
order that the bar segments are stacked.  And I use a slight "offset"
to re-position the legend a little, to make more room for the
annotated image of a christmas tree.

Back to Samples Index