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

---------------------------------------------------------------

The default stacking order of the colored bar segments is alphabetical (or numeric).
Sometimes there is a better order to stack the segments, that makes the bar chart
more intuitive, or makes it 'flow' better.

To do that, I assign numeric values in the data (which I use for the subgroup=).
(then the bar segments are stacked in the numeric order)

data riaa_data;
input year category dollars_per_capita;
datalines;
1973 1 33
1973 2 12
1973 3 2
1974 1 32
1974 2 12
1974 3 2
and so on...

And then have those numeric values print in the legend as the desired text 
by using a user-defined format.

proc format;
value medium
1 = "Vinyl"
2 = "8-Track"
3 = "Cassette"
4 = "CDs"
5 = "Video"
6 = "Digital"
;
run;



Back to Samples Index