Chapter Contents

Previous

Next
The GCHART Procedure

BLOCK Statement


Creates block charts in which the height of the blocks represents the value of the chart statistic for each category of data.

Requirements: At least one chart variable is required.
Global statements: LEGEND, PATTERN, TITLE, FOOTNOTE
Supports: Drill-down functionality



Description

The BLOCK statement specifies the variable or variables that define the categories of data to chart. This statement automatically

You can use statement options to select or order the midpoints (blocks), to change the type of chart statistic, and to modify the appearance of the chart. You can also specify additional variables by which to group, subgroup, or sum the data.

Block charts allow grouping, which organizes the blocks into rows based on the values of a group variable, and subgrouping, which subdivides the blocks into segments based on the values of a subgroup variable.

In addition, you can use global statements to modify the block patterns and the legend, as well as add titles, footnotes, and notes to the chart. You can also use an Annotate data set to enhance the chart.

Note:   If you get a message that the chart is too large to display on your terminal or printer, try one or both of the following:  [cautionend]

See About the Graphics Output Area for a details.

Syntax

BLOCK chart-variable(s) </ option(s);>

option(s) can be one or more options from any or all of the following categories:


Required Arguments

chart-variable(s)
specifies one or more variables that define the categories of data to chart. Each chart variable draws a separate chart. All variables must be in the input data set. Separate multiple chart variables with blanks. The values of a chart variable used with the BLOCK statement have a maximum length of 13.
See also: About Chart Variables


Options

Options in a BLOCK statement affect all graphs produced by that statement. You can specify as many options as you want and list them in any order. For details on specifying colors, see SAS/GRAPH Colors. For a complete description of the graphics options, see Graphics Options and Device Parameters Dictionary.

ANNOTATE=Annotate-data-set
ANNO=Annotate-data-set
specifies a data set to annotate charts produced by the BLOCK statement.

Note:   Annotate coordinate systems 1, 2, 7, and 8 (data system coordinates) are not valid with block charts.  [cautionend]
See also: The Annotate Data Set

BLOCKMAX=max-value
specifies the chart statistic value of the tallest block on the chart. This option lets you produce a series of block charts using the same scale. All blocks are rescaled as if max-value were the maximum value on the chart.

CAXIS=grid-color
specifies the color for the midpoint grid. By default, the midpoint grid uses the foreground color (usually the first color in the colors list).
Featured in: Grouping and Subgrouping a Block Chart

COUTLINE=block-outline-color | SAME
outlines all blocks or all block segments and legend values in the subgroup legend (if it appears) using the specified color. SAME specifies that the outline color of a block or a block segment or a legend value is the same as the interior pattern color.

The default outline color depends on the PATTERN statement:

Note:   If you specify empty patterns, (VALUE=EMPTY in a PATTERN statement) you should not change the outline color from the default value, SAME, to a single color. Otherwise all the outlines will be one color and you will not be able to distinguish between the empty areas.  [cautionend]
See also: Controlling Block Chart Patterns and Colors and About Patterns
Featured in: Grouping and Subgrouping a Block Chart

CTEXT=text-color
specifies a color for all text on the chart. Text includes the values and labels for the midpoint grid, the subgroup legend, and the descriptive statistic values. If you omit CTEXT=, PROC GCHART searches for a color specification in this order:
  1. the CTEXT= option in a GOPTIONS statement

  2. the first color in the colors list (the default).

CTEXT= is overridden by the COLOR= suboption of the LABEL= or VALUE= option in a LEGEND definition assigned to the subgroup legend. The suboption determines the color of the legend label or the color of the legend value descriptions, respectively.

DESCRIPTION='entry-description'
DES='entry-description'
specifies the description of the catalog entry for the chart. The maximum length for entry-description is 40 characters. The description does not appear on the chart. By default, the GCHART procedure assigns a description of the form BLOCK CHART OF variable, where variable is the name of the chart variable.

The entry-description can include the #BYLINE, #BYVAL, and #BYVAR substitution options, which work as they do when used on TITLE, FOOTNOTE, and NOTE statements. For more information, refer to the description of the options, and Substituting BY Line Values in a Text String. The 40-character limit applies before the substitution takes place for these options; thus, if in the SAS program the entry-description text exceeds 40 characters, it is truncated to 40 characters, and then the substitution is performed.

The descriptive text is shown in the "description" portion of each of the following:

DISCRETE
treats a numeric chart variable as a discrete variable rather than as a continuous variable. The GCHART procedure creates a separate midpoint and, hence, a separate grid square and block for each unique value of the chart variable. If the chart variable has a format associated with it, each formatted value is treated as a midpoint.

The LEVELS= option is ignored when you use DISCRETE. The MIDPOINTS= option overrides DISCRETE.

FREQ=numeric-variable
specifies a variable whose values weight the contribution of each observation in the computation of the chart statistic. Each observation is counted the number of times specified by the value of numeric-variable for that observation. If the value of numeric-variable is missing, 0, or negative, the observation is not used in the statistic calculation. Noninteger values of numeric-variable are truncated to integers.

FREQ= is valid with all chart statistics.

Because you cannot use the PERCENT, CPERCENT, FREQ, or CFREQ statistics with the SUMVAR= option, you must use the FREQ= option to calculate percentages, cumulative percentages, frequencies, or cumulative frequencies based on a sum.
See also: Calculating Weighted Statistics

G100
calculates the percentage and cumulative percentage statistics separately for each group. When you use G100, the individual percentages reflect the contribution of the midpoint to the group and total 100 percent for each group. G100 is ignored unless you also use the GROUP= option.

By default, the individual percentages reflect the contribution of the midpoint to the entire chart and total 100 percent for the entire chart.

GROUP=group-variable
organizes the data according to the values of group-variable. Group-variable can be either character or numeric and is always treated as a discrete variable.

GROUP= produces a group grid that contains a separate row of blocks for each unique value of the group variable. Each row contains a square for each midpoint. The groups are arranged from front to back in ascending order of the group variable values. These values are printed to the left of each row; the group variable name or label is printed above the list of group values.

By default, each group includes all midpoints, even if no observations for the group fall within the midpoint range. Missing values for group-variable are treated as a valid group.
Featured in: Grouping and Subgrouping a Block Chart

HTML=variable
identifies the variable in the input data set whose values create links in the HTML file that is created by the ODS HTML statement. These links are associated with an area of the chart and point to the data or graph you wish to display when the user drills down on the area.

HTML_LEGEND=variable
identifies the variable in the input data set whose values create links in the HTML file that is created by the ODS HTML statement. These links are associated with a legend value and point to the data or graph that you wish to display when the user drills down on the value.

LEGEND=LEGEND<1...99>
assigns the specified LEGEND definition to the legend generated by the SUBGROUP= option. The LEGEND= option itself does not generate a legend.

LEGEND= is ignored if

To create a legend based on the chart midpoints instead of the subgroups, use the chart variable as the subgroup variable:

block city / subgroup=city;
See also: LEGEND Statement and SUBGROUP=
Featured in: Grouping and Subgrouping a Block Chart

LEVELS=number-of-midpoints
specifies the number of midpoints for the numeric chart variable. The range for each midpoint is calculated automatically using the algorithm described in Terrell and Scott (1985). LEVELS= is ignored if

MIDPOINTS=value-list
specifies the midpoint values for the blocks. The way you specify value-list depends on the type of variable:

For a complete description of value-list, see the ORDER= option in the AXIS statement.

If value-list for either type of variable specifies so many midpoints that the axis values overwrite each other, the values may be unreadable. In this case the procedure writes a warning to the SAS log. On many devices, you can correct crowded values by increasing the number of cells in your graphics display using the HPOS= and VPOS= graphics options.
See also: About Midpoints
Featured in: Grouping and Subgrouping a Block Chart

MIDPOINTS=OLD
tells the GCHART procedure to calculate default midpoints using the algorithm used in Release 82.4 and Version 5 of SAS/GRAPH software. The MIDPOINTS=OLD option is ignored unless the chart variable is numeric.

MISSING
accepts a missing value as a valid midpoint for the chart variable. By default, observations with missing values are ignored. Missing values are always valid for the group and subgroup variables.

NAME='entry-name'
specifies the name of the catalog entry for the graph. The maximum length for entry-name is eight characters. The default name is GCHART. If the name duplicates an existing entry name, SAS/GRAPH software adds a number to the duplicate name to create a unique name- for example, GCHART1.

NOHEADING
suppresses the heading describing the type of statistic. By default the heading is printed at the top of each block chart.
Featured in: Grouping and Subgrouping a Block Chart

NOLEGEND
suppresses the legend automatically generated by the SUBGROUP= option. NOLEGEND is ignored if the SUBGROUP= option is not used.

PATTERNID=BY | GROUP | MIDPOINT | SUBGROUP
specifies the way fill patterns are assigned. By default, PATTERNID=SUBGROUP. Values for PATTERNID= are as follows:

BY
changes patterns each time the value of the BY variable changes. All blocks use the same pattern if the GCHART procedure does not include a BY statement.

GROUP
changes patterns every time the value of the group variable changes. All blocks in each group (row) use the same pattern, but a different pattern is used for each group.

MIDPOINT
changes patterns every time the midpoint value changes. If you use the GROUP= option, the respective midpoint patterns are repeated for each group.

SUBGROUP
changes patterns every time the value of the subgroup variable changes. The blocks must be subdivided by the SUBGROUP= option for the SUBGROUP value to have an effect. Without SUBGROUP=, all block faces have the same pattern.

Note:   If you use the SUBGROUP= option and specify a PATTERNID= value other than SUBGROUP, the block segments use the same pattern and are indistinguishable.  [cautionend]
See also: Controlling Block Chart Patterns and Colors
Featured in: Creating Bar Charts with Drill-down for the Web

SUBGROUP=subgroup-variable
divides the blocks into segments according to the values of subgroup-variable. Subgroup-variable can be either character or numeric and is always treated as a discrete variable. SUBGROUP= creates a separate segment within each block for every unique value of the subgroup variable for that midpoint.

If PATTERNID=SUBGROUP (the default setting), each segment is filled with a different pattern, and a legend providing a key to the patterns is automatically generated. If the value of PATTERNID= is anything other than SUBGROUP, the segments are all the same color, the legend is suppressed, and the subgrouping effect is lost.

By default the legend appears at the bottom of the chart. To modify the legend, assign a LEGEND definition with the LEGEND= option. To suppress the legend, specify NOLEGEND.
See also: LEGEND Statement
Featured in: Grouping and Subgrouping a Block Chart

SUMVAR=summary-variable
specifies a numeric variable for sum or mean calculations. The GCHART procedure calculates the sum or, if requested, the mean of numeric-variable for each midpoint. The resulting statistics are represented by the height of the blocks in each square. The values of a summary variable used with the BLOCK statement have a maximum length of 8.

When you use SUMVAR=, the TYPE= option value must be either SUM or MEAN. With SUMVAR=, the default is TYPE=SUM.
Featured in: Specifying the Sum Statistic in a Block Chart

TYPE=statistic
specifies the chart statistic.

Because you cannot specify the statistics PERCENT, CPERCENT, FREQ, or CFREQ in conjunction with SUMVAR=, you must use FREQ= to calculate percentages, cumulative percentages, frequencies, or cumulative frequencies based on a sum. See also Calculating Weighted Statistics.

If you specify TYPE=MEAN and use the SUBGROUP= option, the height of the block represents the mean for the entire midpoint. The subgroup segments are proportional to the subgroup's contribution to the sum for the block.
See also: About Chart Statistics
Featured in: Grouping and Subgrouping a Block Chart

WOUTLINE=block-outline-width
specifies the width of the block outline in pixels.


Controlling Block Chart Patterns and Colors

Default patterns and outlines

In a block chart, only the front faces of the blocks display patterns. By default, the procedure

See About Patterns for more information on how the GCHART procedure assigns default patterns and outlines.

User-defined patterns

To override the default patterns and select fills and colors for the blocks or block segments, use the PATTERN statement. Only bar/block patterns are valid; all other pattern fills are ignored. For a complete description of all bar/block patterns, see VALUE= in PATTERN Statement.

Whenever you use PATTERN statements, the default pattern outline color changes to SAME. That is, the outline color is the same as the fill color. To specify the outline color, use the COUTLINE= option.

When patterns change

The PATTERNID= option controls when the pattern changes. By default, PATTERNID=SUBGROUP. Therefore, when you use the SUBGROUP= option to subdivide the blocks, the pattern automatically changes each time the subgroup value changes, and each subdivision of the block displays a different pattern. As a result, the number of values for the SUBGROUP= variable determines the number of block patterns on the chart. If you do not subdivide the blocks, all blocks use the same pattern.

Instead of changing the pattern for each subgroup, you can change the pattern for each midpoint, each group, or each BY group, by changing the value of PATTERNID=. See the PATTERNID= option for details.

Axis color

By default, axis elements use the first color in the colors list. To change the grid color, use the CAXIS= option. To change the axis text color, use the CTEXT= option.


Controlling Block Chart Text

To control the font and size of text on the chart, use the FTEXT= and HTEXT= graphics options. See Graphics Options and Device Parameters Dictionary for a description of these options.

Because block charts do not use AXIS statements, you must use a LABEL statement instead to suppress the label for the midpoint variable. See Grouping and Subgrouping a Block Chart.


Displaying Negative or Zero Values

The relative block heights in the chart represent the scaled value of the chart statistic value for the midpoint. If the statistic has a value of 0 or, in the case of sum and mean, a negative value, the base of the block is drawn in the square for the corresponding midpoint. Block Chart with 0 and Negative Statistic Values shows an example of a chart with 0 and negative statistic values.

Block Chart with 0 and Negative Statistic Values

[IMAGE]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.