GCHART Procedure

Example 7: Specifying the Sum Statistic for a Pie Chart

Features:

PIE statement option SUMVAR=, and PIE3D statement options EXPLODE= and SUMVAR=

Other features:

GOPTIONS statement option BORDER, FORMAT statement, and RUN-group processing

Sample library member: GCHPISUM
This example produces two pie charts that show total sales for three sites by charting the values of the character variable SITE and calculating the sum of the variable SALES for each site. It represents the statistics as slices of the pie. By default, the midpoint value and the summary statistic are printed beside each slice.
The pie slices use the default pattern fill, which is solid. Each slice displays a different color because, by default, pie charts are patterned by midpoint.
GCHPISUM-Specifying the SUM statistic for a PIE chart
The second pie chart is a three-dimensional pie chart with an exploded slice, as shown in the following output.
GCHPISUM-3-D Pie showing SUM statistic

Program

goptions reset=all border;
data totals;
length dept $ 7 site $ 8;
input dept site quarter sales;
datalines;
Parts Sydney 1 7043.97
Parts Atlanta 1 8225.26
Parts Paris 1 5543.97
Tools Sydney 4 1775.74
Tools Atlanta 4 3424.19
Tools Paris 4 6914.25
;
title "Total Sales";
proc gchart data=totals;
format sales dollar8.;
pie site / sumvar=sales;
run;
pie3d site / sumvar=sales
explode="Paris";
run;
quit;

Program Description

Set the graphics environment. The BORDER option in the GOPTIONS statement draws a black border around the graph.
goptions reset=all border;
Create data set TOTALS. TOTALS contains quarterly sales data for three manufacturing sites for one year. Sales figures are broken down by department.
data totals;
length dept $ 7 site $ 8;
input dept site quarter sales;
datalines;
Parts Sydney 1 7043.97
Parts Atlanta 1 8225.26
Parts Paris 1 5543.97
Tools Sydney 4 1775.74
Tools Atlanta 4 3424.19
Tools Paris 4 6914.25
;
Define title.
title "Total Sales";
Produce the first pie chart. The pie statement produces a two dimensional pie chart. The SUMVAR= option calculates the sum of SALES for each value of the chart variable SITE. The default statistic for the SUMVAR= option is SUM. The variable SALES is assigned a dollar format. The embedded RUN statement is required to end this first RUN-Group and honor the action statement and other SAS statements. It signals that the procedure is to remain active.
proc gchart data=totals;
format sales dollar8.;
pie site / sumvar=sales;
run;
Produce the second pie chart. The PIE3D statement produces a three-dimensional pie chart. The EXPLODE= option separates the slice for PARIS from the rest of the pie.
pie3d site / sumvar=sales
explode="Paris";
run;
quit;