Chapter Contents

Previous

Next
The GCHART Procedure

Example 2: Grouping and Subgrouping a Block Chart


Procedure features:
BLOCK statement options:
CAXIS=
COUTLINE=
GROUP=
LEGEND=
MIDPOINTS=
NOHEADING
SUBGROUP=
TYPE=
Other features:
LABEL statement
LEGEND statement
Default pattern rotation
Data set: TOTALS
Sample library member: GR13N02

[IMAGE]

This example shows average quarterly sales for each department at two of the three manufacturing sites in the TOTALS data set; it excludes the Paris site from the chart.

The program groups the chart data (sites) by department, and subgroups department sales data by quarter. Each site is a midpoint. Because the sites are grouped by department, each midpoint has a separate square for each department and the height of the block represents total sales for that department.

The blocks are subgrouped to show how quarterly sales contribute to total sales; each segment represents sales for a quarter. A legend explaining the subgroup patterns appears below the midpoint grid.

The subgroups use four default patterns, The first three patterns are created by rotating the first default fill, solid, through the three colors in the colors list defined in the GOPTIONS statement. The fourth default pattern is created by using the second default pattern fill, X1, with the first color in the colors list, blue.

Because the first color in the colors list is also the default color for several other elements, the program includes several options that override the default: CTEXT= colors all text, CAXIS= colors the midpoint grid, COUTLINE= colors the pattern outline. For more information on patterns and colors, see Controlling Block Chart Patterns and Colors.
 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(blue green red) ctext=black
         ftitle=swissb ftext=swiss htitle=4 htext=3;
 Note about code
title 'Average Sales by Department';
footnote j=r 'GR13N02  ';
 Note about code
legend1 cborder=black
        label=('Quarter:')
        position=(middle left outside)
        mode=protect
        across=1;
 Note about code
proc gchart data=reflib.totals;
   format quarter roman.;
   format sales dollar8.;
   label site='00'x dept='00'x;
 Note about code
   block site / sumvar=sales
                type=mean
                midpoints='Sydney' 'Atlanta'
                group=dept
                subgroup=quarter
                legend=legend1
                noheading
                coutline=black
                caxis=black;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.