CHART Procedure

VBAR Statement

Produces a vertical bar chart.
Producing a Simple Frequency Count

Producing a Percentage Bar Chart

Subdividing the Bars into Categories

Producing Side-by-Side Bar Charts


Required Argument

specifies the variables for which PROC CHART produces a vertical bar chart, one chart for each variable.

Optional Arguments

prints the bars and any associated statistics in ascending order of size within groups.
specifies the values for the response axis, where value-expression is a list of individual values, each separated by a space, or a range with a uniform interval for the values. For example, the following range specifies tick marks on a bar chart from 0 to 100 at intervals of 10: hbar x / axis=0 to 100 by 10;
Restrictions:Values must be uniformly spaced, even if you specify them individually.

For frequency charts, values must be integers.

Interactions:For HBAR and VBAR charts, AXIS= determines tick marks on the response axis. If the AXIS= specification contains only one value, then the value determines the minimum tick mark if the value is less than 0, or determines the maximum tick mark if the value is greater than 0.

If you use AXIS= and the BY statement, then PROC CHART produces uniform axes over BY groups.

Values in value-expression override the range of the data.
For example, if the data range is 1 to 10 and you specify a range of 3 to 5, then only the data in the range 3 to 5 appears on the chart. Values out of range produce a warning message in the SAS log.
specifies that a numeric chart variable is discrete rather than continuous. Without DISCRETE, PROC CHART assumes that all numeric variables are continuous and automatically chooses intervals for them unless you use MIDPOINTS= or LEVELS=.
specifies a data set variable that represents a frequency count for each observation. Normally, each observation contributes a value of one to the frequency counts. With FREQ=, each observation contributes its value of the FREQ= value.
Restriction:If the FREQ= values are not integers, then PROC CHART truncates them.
Interaction:If you use SUMVAR=, then PROC CHART multiplies the sums by the FREQ= value.
produces side-by-side charts, with each chart representing the observations that have a common value for the GROUP= variable. The GROUP= variable can be character or numeric and is assumed to be discrete. For example, the following statement produces a frequency bar chart for men and women in each department:
   vbar gender / group=dept;
Missing values for a GROUP= variable are treated as valid levels.
specifies the amount of extra space between groups of bars. Use GSPACE=0 to leave no extra space between adjacent groups of bars.
Interaction:PROC CHART ignores GSPACE= if you omit GROUP=
specifies that the sum of percentages for each group equals 100. By default, PROC CHART uses 100% as the total sum. For example, if you produce a bar chart that separates males and females into three age categories, then the six bars, by default, add to 100%. However, with G100, the three bars for females add to 100%, and the three bars for males add to 100%.
Interaction:PROC CHART ignores G100 if you omit GROUP=.
specifies the number of bars that represent each chart variable when the variables are continuous.
MIDPOINTS=midpoint-specification | OLD
defines the range of values that each bar, block, or section represents by specifying the range midpoints.
The value for MIDPOINTS= is one of the following:
specifies midpoints, either individually, or across a range at a uniform interval. For example, the following statement produces a chart with five bars; the first bar represents the range of values of X with a midpoint of 10, the second bar represents the range with a midpoint of 20, and so on:
   vbar x / midpoints=10 20 30 40 50;
Here is an example of a midpoint specification for a character variable:
   vbar x / midpoints='JAN' 'FEB' 'MAR';
Here is an example of specifying midpoints across a range at a uniform interval:
   vbar x / midpoints=10 to 100 by 5;
specifies an algorithm that PROC CHART used in previous versions of SAS to choose midpoints for continuous variables. The old algorithm was based on the work of Nelder (1976). The current algorithm that PROC CHART uses if you omit OLD is based on the work of Terrell and Scott (1985).
Default:Without MIDPOINTS=, PROC CHART displays the values in the SAS System's normal sorted order.
Restriction:When the VBAR variables are numeric, the midpoints must be given in ascending order.
specifies that missing values are valid levels for the chart variable.
suppresses printing of the subgroup symbol or legend table.
Interaction:PROC CHART ignores NOSYMBOL if you omit SUBGROUP=.
suppresses any bar with zero frequency.
draws reference lines on the response axis at the specified positions.
Tip:The REF= values should correspond to values of the TYPE= statistic.
specifies the amount of space between individual bars.
Tips:Use SPACE=0 to leave no space between adjacent bars.

Use the GSPACE= option to specify the amount of space between the bars within each group.

subdivides each bar or block into characters that show the contribution of the values of variable to that bar or block. PROC CHART uses the first character of each value to fill in the portion of the bar or block that corresponds to that value, unless more than one value begins with the same first character. In that case, PROC CHART uses the letters A, B, C, and so on, to fill in the bars or blocks. If the variable is formatted, then PROC CHART uses the first character of the formatted value.
The characters used in the chart and the values that they represent are given in a legend at the bottom of the chart. The subgroup symbols are ordered A through Z and 0 through 9 with the characters in ascending order.
PROC CHART calculates the height of a bar or block for each subgroup individually and then rounds the percentage of the total bar up or down. So the total height of the bar can be higher or lower than the same bar without the SUBGROUP= option.
Interaction:If you use both TYPE=MEAN and SUBGROUP=, then PROC CHART first calculates the mean for each variable that is listed in the SUMVAR= option. It then subdivides the bar into the percentages that each subgroup contributes.
specifies the variable for which either values or means (depending on the value of TYPE=) PROC CHART displays in the chart.
Interaction:If you use SUMVAR= and you use TYPE= with a value other than MEAN or SUM, then TYPE=SUM overrides the specified TYPE= value.
Tip:VBAR charts can print labels for SUMVAR= variables if you use a LABEL statement.
specifies the character or characters that PROC CHART uses in the bars or blocks of the chart when you do not use the SUBGROUP= option.
Default:asterisk (*)
Interaction:If the SAS system option OVP is in effect and if your printing device supports overprinting, then you can specify up to three characters to produce overprinted charts.
specifies what the bars or sections in the chart represent. The statistic is one of the following:
specifies that each bar, block, or section represent the cumulative frequency.
specifies that each bar, block, or section represent the cumulative percentage.
specifies that each bar, block, or section represent the frequency with which a value or range occurs for the chart variable in the data.
specifies that each bar, block, or section represent the mean of the SUMVAR= variable across all observations that belong to that bar, block, or section.
Interaction:With TYPE=MEAN, you can compute only MEAN and FREQ statistics.
specifies that each bar, block, or section represent the percentage of observations that have a given value or that fall into a given range of the chart variable.
specifies that each bar, block, or section represent the sum of the SUMVAR= variable for the observations that correspond to each bar, block, or section.
Default:FREQ (unless you use SUMVAR=, which causes a default of SUM)
Interaction:With TYPE=SUM, you can compute only SUM and FREQ statistics.
specifies the width of the bars on bar charts.


Statement Results

PROC CHART prints one page per chart. Along the vertical axis, PROC CHART describes the chart frequency, the cumulative frequency, the chart percentage, the cumulative percentage, the sum, or the mean. At the bottom of each bar, PROC CHART prints a value according to the value of the TYPE= option, if specified. For character variables or discrete numeric variables, this value is the actual value represented by the bar. For continuous numeric variables, the value gives the midpoint of the interval represented by the bar.
PROC CHART can automatically scale the vertical axis, determine the bar width, and choose spacing between the bars. However, by using options, you can choose bar intervals and the number of bars, include missing values in the chart, produce side-by-side charts, and subdivide the bars. If the number of characters per line (LINESIZE=) is not sufficient to display all vertical bars, then PROC CHART produces a horizontal bar chart instead.