Displaying Groups within a Bar -- Character Variable - SAS Programming

There is one more way to represent another variable in a chart—you can use the SUBGROUP= option of the VBAR or HBAR statement to specify that you want the bar-plotting symbol (default is *) to represent values of another variable. For example, if you want to see the sales frequencies by REGION and also want to see which items contributed to these sales, you can include ITEM as a subgroup.The modified code is:


TITLE 'Vertical Bar Chart with SUBGROUP= Option';

Notice in the following output that the bars are made up of H's (hammers), S's (saws), and P's (pliers).The first letter of each ITEM value is used to create the bars,and the output includes a legend below the graph.

Output from Example - Displaying Groups within a Bar — Character Variable

Output from Example - Displaying Groups within a Bar — Character Variable

As you can see, the height of the bars shows the total number of items sold in each of the four regions. The subdivisions within each bar show, by the appropriate charting symbol, how many hammers, pliers, and saws make up this total.

Now what, you might ask, would the system do if the inventory included screwdrivers as well as saws, both beginning with "S." It's simple. The system would simply substitute sequential letters starting with A, B, C, etc. until the series was sufficient to account for all the data. Satisfied?

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAS Programming Topics