CHART Procedure

Example 5: Producing a Horizontal Bar Chart for a Subset of the Data

Features:
HBAR statement options:
GROUP=
SUMVAR=
Other features:

WHERE= data set option

Data set: PIESALES

Details

This example does the following:
  • produces horizontal bar charts only for observations with a common value
  • charts the values of a variable for the categories of another variable
  • creates side-by-side bar charts for the categories of a third variable

Program

proc chart data=piesales(where=(year=2005));
   hbar bakery / group=flavor
   sumvar=pies_sold;
   title '2005 Pie Sales for Each Bakery According to Flavor';
run;

Program Description

Specify the variable value limitation for the horizontal bar chart. WHERE= limits the chart to only the 2005 sales totals.
proc chart data=piesales(where=(year=2005));
Create a side-by-side horizontal bar chart. The HBAR statement produces a side-by-side horizontal bar chart to compare sales across values of Flavor, specified by GROUP=. Each Flavor group contains a bar for each Bakery value.
   hbar bakery / group=flavor
Specify the bar length variable. SUMVAR= specifies Pies_Sold as the variable whose values are represented by the lengths of the bars.
   sumvar=pies_sold;
Specify the title.
   title '2005 Pie Sales for Each Bakery According to Flavor';
run;

Output: HTML

2005 Pie Sales for Each Bakery According to Flavor