Sample 25520: Grouping and arranging Pie Charts using PROC GCHART
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 1, Chapter 13.
For additional information on the sample refer to this book.
/*+-----------------------------------------------------+
| S A S S A M P L E L I B R A R Y |
| |
| NAME: GCHPIGRP |
| TITLE: GCHPIGRP-Grouping and Arranging Pie Charts |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS GCHART |
| PROCS: GCHART |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
+-----------------------------------------------------+*/
/* Set the graphics environment */
goptions reset=all gunit=pct border cback=white
colors=(black blue green red) ftitle=swissb
ftext=swiss htitle=5 htext=3.5;
/* Create the data set ENPROD */
data enprod;
length engytype $ 8;
input year engytype produced;
datalines;
1985 Coal 19.33
1985 Gas 19.22
1985 Petro 18.99
1985 Nuclear 4.15
1985 Hydro 2.97
1985 Geotherm .20
1985 Biofuels .01
1995 Coal 21.98
1995 Gas 21.54
1995 Petro 13.89
1995 Nuclear 7.18
1995 Hydro 3.21
1995 Geotherm .31
1995 Biofuels 2.95
;
/* Define title and footnote for chart */
title 'Changes in Energy Production:1985 to 1995';
footnote h=3 j=r 'GCHPIGRP ';
/* Assign a color to each energy type */
pattern1 color=black; /* biofuels */
pattern2 color=blue; /* coal */
pattern3 color=green; /* gas */
pattern4 color=gray; /* geothermal */
pattern5 color=lipk; /* hydoelectric */
pattern6 color=lime; /* nuclear */
pattern7 color=cyan; /* petro */
pattern8 color=red; /* other */
/* Generate pie chart */
proc gchart data=enprod;
label year='00'x;
pie engytype / sumvar=produced
other=5
otherlabel='Renewable'
group=year
across=2
clockwise
value=none
slice=outside
percent=outside
coutline=black
noheading;
run;
quit;

This example uses the GROUP= option to display multiple graphs on a page. It also uses the ACROSS= option to define how the pie charts are displayed.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Pie
|
| Date Modified: | 2005-08-24 16:06:36 |
| Date Created: | 2005-05-23 14:12:55 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |