Chapter Contents

Previous

Next
The GCHART Procedure

Example 9: Subgrouping a Donut or Pie Chart


Procedure features:
DONUT statement options:
COUTLINE=
CTEXT=
DONUTPCT=
LABEL=
LEGEND=
NOHEADING
SUBGROUP=
Other features: LEGEND statement
Data set: TOTALS
Sample library member: GR13N09

[IMAGE]

This example produces a donut chart that is similar to the pie chart in Specifying the Sum Statistic for a Pie Chart in that each slice represents total sales for a site and each slice is a different color. However, in this donut chart the sites are subgrouped by department, so that each department is represented as a concentric ring with slices.

Subgrouping suppresses the chart statistic and the midpoint labels. Instead it automatically labels the rings with the subgroup values and generates a legend that shows how the patterns are associated with the midpoint values. Subgrouping a pie chart produces the same results but without the hole in the center.

To allow the donut chart to be as large as possible, the program suppresses the default heading and moves the legend into the space at the left of the chart.
 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(blue green red) ctext=black
         ftext=swissb ftext=swiss htitle=6 htext=4;
 Note about code
title 'Sales by Site and Department';
footnote h=3 j=r 'GR13N09 ';
 Note about code
legend1 label=none
        shape=bar(4,4)
        position=(middle left)
        offset=(5,)
        across=1
        mode=share;
 Note about code
proc gchart data=reflib.totals;
   format sales dollar8.;
   donut site / sumvar=sales
                subgroup=dept
                donutpct=30
                label=('All' justify=center 'Quarters')
                noheading
                legend=legend1
                coutline=black
                ctext=black;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

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