Chapter Contents

Previous

Next
The GCHART Procedure

Example 11: Assigning Patterns and Identifying Midpoints with a Legend


Procedure features:
PIE statement options:
COUTLINE=
CTEXT=
DESCENDING
LEGEND=
OTHER=
OTHERLABEL=
VALUE=INSIDE
Other features:
LEGEND statement
PATTERN statement
Data set: ENPROD
Sample library member: GR13N11

[IMAGE]

This example shows the actual amount of energy that is produced by each source for 1985. It displays the chart statistic inside each slice and uses a legend instead of slice labels to identify the slices. Pattern colors are assigned explicitly to each energy source.

All of the variables with midpoint values less than or equal to 5 percent of the total (in this case, biofuels, geotherm, and hydro) are grouped into one slice labeled "Other." The slices are ordered from largest to smallest based on the statistic value. Although the "Other" slice is always last, it is in this case also the smallest.
 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red) ftitle=swissb
         ftext=swiss htitle=5 htext=4;
 Note about code
title1 'Principle Sources of Energy: 1985';
title2 font=swissb h=4.5 '(Amounts in quadrillion btu)';
footnote h=3 j=r 'GR13N11 ';
 Note about code
pattern1 color=black;       /* biofuels     */
pattern2 color=blue;        /* coal         */
pattern3 color=green;       /* gas          */
pattern4 color=gray;        /* geothermal   */
pattern5 color=lipk;        /* hydroelectric */
pattern6 color=lime;        /* nuclear      */
pattern7 color=cyan;        /* petro        */
pattern8 color=red;         /* other        */
 Note about code
legend1 label=none
        position=(left middle)
        offset=(4,)
        across=1
        order=('Coal' 'Gas' 'Petro'
               'Nuclear' 'Other')
        value=(color=black)
        shape=bar(4,4);
 Note about code
proc gchart data=reflib.enprod(where=(year=1985));
   pie engytype / sumvar=produced
                  other=5
                  otherlabel='Renewable'
                  descending
                  legend=legend1
                  value=inside
                  ctext=white
                  coutline=black
                  noheading;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

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