Creating Bar and Pie Charts |
Lesson
Summary![]() ![]() |
This page contains
|
I. Text Summary
To go to the page where a task, programming feature, or concept was presented, select a link. |
Overview of the GCHART Procedure Using the GCHART procedure, you can create 2D or 3D horizontal bar charts, vertical bar charts, or pie charts. When you use the GCHART procedure, you must
|
Specifying the Chart Type and Variables For character chart variables, SAS/GRAPH software creates one bar or slice for each unique value. Unless otherwise specified, SAS/GRAPH assumes all numeric chart variables are continuous. SAS/GRAPH software automatically determines intervals for continuous variables and creates one bar or pie slice for each interval. The intervals are identified by their midpoint values. |
Specifying Statistics The default statistic for GCHART is FREQ (frequency). You use the TYPE= option to display a statistic other than frequency. Statistics include CFREQ (cumulative frequency), PERCENT (percent), and CPERCENT (cumulative percent). The type of chart affects what statistics you may specify. The statistics CFREQ (cumulative frequency) and CPERCENT (cumulative percent) are not available for pie charts. |
Summarizing a Variable within
Categories The SUMVAR= option lets you summarize one variable (the summary variable) within categories that are defined by a second variable (the chart variable). When you specify a summary variable, the default statistic is SUM. You can combine the SUMVAR= option with TYPE=MEAN to request the average of the values of the summary variable for each unique value of the chart variable. You can use the TYPE=MEAN option only with the SUMVAR= option. |
Selecting Observations You can use the WHERE statement to select which observations to include in your statistics. For example, you could include only observations where the value of the variable Age is greater than 50.
The WHERE statement works the same with PROC GCHART as it does with other
PROC steps. |
Enhancing Charts You can enhance your charts by specifying colors and patterns for bars or slices other than the defaults. PATTERNID=MIDPOINT specifies that bar colors and patterns vary for each bar. For pie charts, the FILL=X option specifies that all slices be cross-hatched. The colors of the slices are not changed. FILL=S specifies that all slices be a solid color. |
Using RUN-Group Processing When you are modifying your SAS/GRAPH output, you can also take advantage of RUN-group processing. This means that when running in interactive mode, you can submit additional statements to enhance your output without resubmitting the PROC step that created it. |
Viewing and Storing Charts As you create charts, you can view individual graphs by scrolling in the GRAPH window or by selecting them in the Results window. To store your graphs, you can use the GOUT= option in the GCHART statement to specify a temporary or permanent output catalog. You can also view and manage entries stored in catalogs. |
Additional Features There are many other features available in the GCHART procedure. For bar charts, you can use the GROUP= option, the SUBGROUP= option, the PATTERNID=SUBGROUP option, and multiple PATTERN statements. For horizontal bar charts, you can control which statistics are displayed. For pie charts, you can specify text color by using the CTEXT= option, control where labels appear by using the SLICE= option, and explode one or more pie slices for effect by using the EXPLODE= option. You can easily create three dimensional charts by using the PIE3D, VBAR3D, and HBAR3D statements. |
|
II. Syntax
To go to the page where a statement or option was presented, select a link. |
|
III. Sample Program
libname mylib 'd:\reports\permcat'; proc gchart data=clinic.admit gout=mylib.permcat; hbar sex / type=freq patternid=midpoint group=actlevel; hbar3d sex / type=freq patternid=midpoint group=actlevel; vbar age / sumvar=weight; vbar3d age / sumvar=weight; pie age / sumvar=weight type=mean fill=x; pie3d age / sumvar=weight type=mean; where age>35; run;
|
IV. Points to Remember
|
![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.