Previous Page | Next Page

The CHART Procedure

Customizing All Types of Charts


Many options in PROC CHART are valid in more than one statement. This section describes the options that you can use on the chart-producing statements.

Task Option
Specify that numeric variables are discrete DISCRETE
Specify a frequency variable FREQ=
Specify that missing values are valid levels MISSING
Specify the variable for which values or means are displayed SUMVAR=
Specify the statistic represented in the chart TYPE=
Specify groupings

Group the bars in side-by-side charts GROUP=

Specify that group percentages sum to 100 G100

Specify the number of bars for continuous variables LEVELS=

Define ranges for continuous variables MIDPOINTS=

Divide the bars into categories SUBGROUP=
Compute statistics

Compute the cumulative frequency for each bar CFREQ

Compute the cumulative percentage for each bar CPERCENT

Compute the frequency for each bar FREQ

Compute the mean of the observations for each bar MEAN

Compute the percentage of total observations for each bar PERCENT

Compute the total number of observations for each bar SUM
Control output format

Print the bars in ascending order of size ASCENDING

Specify the values for the response axis AXIS=

Print the bars in descending order of size DESCENDING

Specify extra space between groups of bars GSPACE=

Suppress the default header line NOHEADER

Allow no space between vertical bars NOSPACE

Suppress the statistics NOSTATS

Suppress the subgroup legend or symbol table NOSYMBOL

Suppress the bars with zero frequency NOZEROS

Draw reference lines REF=

Specify the spaces between bars SPACE=

Specify the symbols within bars or blocks SYMBOL=

Specify the width of bars WIDTH=


Options

ASCENDING

prints the bars and any associated statistics in ascending order of size within groups.

Alias: ASC
Restriction: Available only on the HBAR and VBAR statements
AXIS=value-expression

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;
Restriction: Not available on the PIE statement
Restriction: Values must be uniformly spaced, even if you specify them individually.
Restriction: For frequency charts, values must be integers.
Interaction: For BLOCK charts, AXIS= sets the scale of the tallest block. To set the scale, PROC CHART uses the maximum value from the AXIS= list. If no value is greater than 0, then PROC CHART ignores the AXIS= option.
Interaction: 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.
Interaction: For STAR charts, a single AXIS= value sets the minimum (the center of the chart) if the value is less than zero, or sets the maximum (the outside circle) if the value is greater than zero. If the AXIS= specification contains more than one value, then PROC CHART uses the minimum and maximum values from the list.
Interaction: If you use AXIS= and the BY statement, then PROC CHART produces uniform axes over BY groups.
CAUTION:
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.  [cautionend]

CFREQ

prints the cumulative frequency.

Restriction: Available only on the HBAR statement
CPERCENT

prints the cumulative percentages.

Restriction: Available only on the HBAR statement
DESCENDING

prints the bars and any associated statistics in descending order of size within groups.

Alias: DESC
Restriction: Available only on the HBAR and VBAR statements
DISCRETE

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=.

FREQ

prints the frequency of each bar to the side of the chart.

Restriction: Available only on the HBAR statement
FREQ=variable

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.
GROUP=variable

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.

Restriction: Available only on the BLOCK, HBAR, and VBAR statements
Featured in: Producing Side-by-Side Bar Charts, Producing a Horizontal Bar Chart for a Subset of the Data, Producing Block Charts for BY Groups
GSPACE=n

specifies the amount of extra space between groups of bars. Use GSPACE=0 to leave no extra space between adjacent groups of bars.

Restriction: Available only on the HBAR and VBAR statements
Interaction: PROC CHART ignores GSPACE= if you omit GROUP=
G100

specifies that the sum of percentages for each group equals 100. By default, PROC CHART uses 100 percent 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 percent; however, with G100, the three bars for females add to 100 percent, and the three bars for males add to 100 percent.

Restriction: Available only on the BLOCK, HBAR, and VBAR statements
Interaction: PROC CHART ignores G100 if you omit GROUP=.
LEVELS=number-of-midpoints

specifies the number of bars that represent each chart variable when the variables are continuous.

MEAN

prints the mean of the observations represented by each bar.

Restriction: Available only on the HBAR statement and only when you use SUMVAR= and TYPE=
Restriction: Not available when TYPE=CFREQ, CPERCENT, FREQ, or PERCENT
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:

midpoint-specification

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;
OLD

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.
MISSING

specifies that missing values are valid levels for the chart variable.

NOHEADER

suppresses the default header line printed at the top of a chart.

Alias: NOHEADING
Restriction: Available only on the BLOCK, PIE, and STAR statements
Featured in: Producing Block Charts for BY Groups
NOSTATS

suppresses the statistics on a horizontal bar chart.

Alias: NOSTAT
Restriction: Available only on the HBAR statement
NOSYMBOL

suppresses printing of the subgroup symbol or legend table.

Alias: NOLEGEND
Restriction: Available only on the BLOCK, HBAR, and VBAR statements
Interaction: PROC CHART ignores NOSYMBOL if you omit SUBGROUP=.
NOZEROS

suppresses any bar with zero frequency.

Restriction: Available only on the HBAR and VBAR statements
PERCENT

prints the percentages of observations having a given value for the chart variable.

Restriction: Available only on the HBAR statement
REF=value(s)

draws reference lines on the response axis at the specified positions.

Restriction: Available only on the HBAR and VBAR statements
Tip: The REF= values should correspond to values of the TYPE= statistic.
Featured in: Producing Side-by-Side Bar Charts
SPACE=n

specifies the amount of space between individual bars.

Restriction: Available only on the HBAR and VBAR statements
Tip: Use SPACE=0 to leave no space between adjacent bars.
Tip: Use the GSPACE= option to specify the amount of space between the bars within each group.
SUBGROUP=variable

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.

Restriction: Available only on the BLOCK, HBAR, and VBAR statements
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, then subdivides the bar into the percentages that each subgroup contributes.
Featured in: Subdividing the Bars into Categories
SUM

prints the total number of observations that each bar represents.

Restriction: Available only on the HBAR statement and only when you use both SUMVAR= and TYPE=
Restriction: Not available when TYPE=CFREQ, CPERCENT, FREQ, or PERCENT
SUMVAR=variable

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: Both HBAR and VBAR charts can print labels for SUMVAR= variables if you use a LABEL statement.
Featured in: Subdividing the Bars into Categories, Producing Side-by-Side Bar Charts, Producing a Horizontal Bar Chart for a Subset of the Data, Producing Block Charts for BY Groups
SYMBOL=character(s)

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 (*)
Restriction: Available only on the BLOCK, HBAR, and VBAR statements
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.
Featured in: Producing Block Charts for BY Groups
TYPE=statistic

specifies what the bars or sections in the chart represent. The statistic is one of the following:

CFREQ

specifies that each bar, block, or section represent the cumulative frequency.

CPERCENT

specifies that each bar, block, or section represent the cumulative percentage.

Alias: CPCT
FREQ

specifies that each bar, block, or section represent the frequency with which a value or range occurs for the chart variable in the data.

MEAN

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.
Featured in: Producing Side-by-Side Bar Charts
PERCENT

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.

Alias: PCT
Featured in: Producing a Percentage Bar Chart
SUM

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.
WIDTH=n

specifies the width of the bars on bar charts.

Restriction: Available only on the HBAR and VBAR statements

Previous Page | Next Page | Top of Page