SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Bar and Pie Charts
Specifying the Chart Type and Variables


After you invoke the GCHART procedure and specify the data set to use, you specify
  • the type of chart you want to create (horizontal bar chart, vertical bar chart, or pie chart)
  • the chart variable that determines the number of bars or pie slices to create.

Whether the chart variable is character or numeric determines the number of bar or pie slices in your chart.


Character Chart Variables

PROC GCHART creates one bar or pie slice for each unique value of a character variable. For example, the HBAR statement below specifies a horizontal bar chart of the character variable Sex, so the chart displays a bar for each value.

     proc gchart data=clinic.admit;
        hbar sex;
     run;

Horizontal bar chart example.


Numeric Chart Variables

Unless otherwise specified, SAS/GRAPH software assumes that all numeric 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.

In the program below, the VBAR statement specifies a vertical bar chart of the numeric variable Age, so SAS/GRAPH software automatically determines intervals and labels them with their midpoint values.

     proc gchart data=clinic.admit;
        vbar age;
     run;

Vertical bar chart example.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement