SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Bar and Pie Charts
Summarizing a Variable within Categories


In addition to specifying a particular statistic for your chart, you may want to summarize one variable within categories defined by a second variable. You can use the SUMVAR= option to summarize a variable within categories.


General form, PROC GCHART step with SUMVAR= option:
PROC GCHART <DATA=SAS-data-set>;
        chart-form chart-variable /
                          SUMVAR=
summary-variable;

RUN;

where the values of summary-variable are summarized for each unique value of chart-variable.

NOTE: When you specify SUMVAR=, the default statistic is SUM, so the chart displays the total of the values of the summary variable for each unique value of the chart variable.

NOTE: When you use SUMVAR=, you can also use TYPE=. However, the value of TYPE= can be only SUM or MEAN.


Example

The GCHART step below specifies the summary variable BalanceDue (balance due). The bars represent the sum of the values of BalanceDue for each value of Company (total balance due by company). Notice that the default statistic is SUM.

     proc gchart data=clinic.insure;
        vbar company / sumvar=balancedue;
     run;

Vertical bar chart with analysis variable.

Without the summary variable, the GCHART procedure displays the frequency of the chart variable Company (the number of people who have a policy with each company).
     proc gchart data=clinic.insure;
        vbar company;
     run;

Vertical bar chart.


back||next


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

Terms of Use & Legal Information | Privacy Statement