CHART Procedure

HBAR Statement

Produces a horizontal bar chart.
Tip: HBAR charts can print either the name or the label of the chart variable.
See: Producing a Horizontal Bar Chart for a Subset of the Data


Required Argument

specifies the variables for which PROC CHART produces a horizontal 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.
prints the cumulative frequency.
Restriction:Available only in the HBAR statement
prints the cumulative percentages.
Restriction:Available only in the HBAR statement
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=.
prints the frequency of each bar to the side of the chart.
Restriction:Available only in the HBAR statement
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.
prints the mean of the observations represented by each bar.
Restrictions:Available only when you use SUMVAR= and TYPE=


specifies that missing values are valid levels for the chart variable.
suppresses the statistics on a horizontal bar chart.
suppresses printing of the subgroup symbol or legend table.
Interaction:PROC CHART ignores NOSYMBOL if you omit SUBGROUP=.
suppresses any bar with zero frequency.
prints the percentages of observations having a given value for the chart variable.
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.
prints the total number of observations that each bar represents.
Restrictions:Available only when you use both SUMVAR= and TYPE=


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:HBAR 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

Each chart occupies one or more output pages, depending on the number of bars; each bar occupies one line, by default.
By default, for horizontal bar charts of TYPE=FREQ, CFREQ, PCT, or CPCT, PROC CHART prints the following statistics: frequency, cumulative frequency, percentage, and cumulative percentage. If you use one or more of the statistics options, then PROC CHART prints only the statistics that you request, plus the frequency.