GCHART Procedure

HBAR, HBAR3D, VBAR, and VBAR3D Statement

Create horizontal or vertical bar charts in which the length or height of the bars represents the value of the chart statistic for each category of data.
Requirement: At least one chart variable is required.
Global statements: AXIS, FOOTNOTE, LEGEND, PATTERN, TITLE
Supports: Drill-down functionality

Syntax

HBAR | HBAR3D | VBAR | VBAR3D chart-variable(s) </ options>;

Summary of Optional Arguments

Appearance options
specifies a data set to annotate all graphs that are produced by the GCHART procedure.
specifies the color of reference lines drawn at major tick marks, as determined by the AUTOREF option.
specifies a color for the response and midpoint axis lines and for the default axis area frame.
specifies the color of error bars in bar charts.
specifies the color with which to fill the axis area in two-dimensional bar charts or the floor, back wall, and side wall of three-dimensional bar charts.
specifies the confidence intervals to use when drawing error bars.
outlines all bars or bar segments and legend values in the subgroup legend (if it appears) using the specified color.
specifies colors for reference lines.
specifies a color for all text on the axes and legend, including axis labels, tick mark values, legend labels, and legend value descriptions.
specifies whether a line is drawn around the axis area of a two-dimensional bar chart or a back wall is drawn in a three-dimensional bar chart.
specifies the amount of extra space between groups of bars.
identifies the image file that you want to apply to a two-dimensional chart's axis area or a three-dimensional chart's back wall.
specifies whether to use multiple instances of an image, or stretch a single image.
specifies the line type for reference lines at major tick marks, as determined by the AUTOREF option.
assigns the specified LEGEND definition to the legend generated by the SUBGROUP= option.
specifies line types for reference lines.
suppresses the legend that is automatically generated by the SUBGROUP= option.
suppresses the legend that is automatically generated by the SUBGROUP= option.
specifies how fill patterns are assigned.
specifies the shape of the bars in charts that are produced with the HBAR3D and VBAR3D statements.
specifies the amount of space between individual bars or between the bars within each group if you also use the GROUP= option.
displays a list of the subgroup values of the specified statistic above the bars.
specifies the line width for reference lines at major tick marks, as determined by the AUTOREF option.
specifies the width of the bars.
specifies the width of the outline in pixels.
specifies line widths for reference lines.
Axis options
arranges the bars in ascending order of the value of the chart statistic.
draws a reference line at each major tick mark on the response axis.
specifies values for the major tick marks or assigns specified AXIS definitions to the axis.
clips the reference lines at the bars.
arranges the bars in descending order of the value of the chart statistic.
specifies that reference lines drawn by the AUTOREF or REF= options should be drawn in front of the bars.
assigns the specified AXIS definition to the group axis.
assigns the specified AXIS definition to the midpoint axis.
specifies the number of minor tick marks between each major tick mark on the response axis.
suppresses all axes, including axis lines, axis labels, axis values, and all major and minor tick marks.
suppresses the zero reference line when the SUM or MEAN chart statistic has negative values.
suppresses any midpoints for which there are no corresponding values of the chart variable and, hence, no bar.
displays on the axis of the chart the range of numeric values represented by each bar.
specifies values for the major tick mark divisions on the response axis or assigns the specified AXIS definition to the axis.
draws reference lines at the specified points on the response axis.
Catalog entry description options
specifies a description of the output.
specifies the name of the GRSEG catalog entry and the name of the graphics output file, if one is created.
Midpoint options
treats a numeric chart variable as a discrete variable rather than as a continuous variable.
organizes the data according to values of group-variable.
specifies the number of midpoints to be graphed for a chart variable.
generates default midpoints using the Nelder algorithm (Applied Statistics 25:94–7, 1976).
specifies the midpoint values for the bars.
accepts a missing value as a valid midpoint for the chart variable.
divides the bars into segments according to the values of subgroup-variable.
ODS options
identifies the variable in the input data set whose values create links.
identifies the variable in the input data set whose values create links or data tips or both.
specifies a character variable whose values are URLs.
Statistic options
displays the cumulative frequency statistic in the table of statistics and above vertical bars.
specifies the text of the column label for the CFREQ statistic in the table of statistics.
displays the cumulative percentage statistic in the table of statistics and above vertical bars.
specifies the text of the column label for the CPERCENT statistic in the table of statistics.
draws confidence levels.
displays the frequency statistic in the table of statistics and above vertical bars.
specifies a variable whose values weight the contribution of each observation in the computation of the chart statistic.
specifies the text of the column label for the FREQ statistic in the table of statistics.
calculates the percentage and cumulative percentage statistics separately for each group.
displays the values of the specified statistic inside the bars.
displays the mean statistic in the table of statistics and above vertical bars.
specifies the text of the column label for the MEAN statistic in the table of statistics.
suppresses the table of statistics.
displays the values of the specified statistic above the bars.
prints the percentages of observations having a given value for the chart variable in the table of statistics and above vertical bars.
specifies the text of the column label for the PERCENT statistic in the table of statistics.
calculates a percent of the sum variable for horizontal bar charts.
displays the sum statistic in the table of statistics and above vertical bars.
specifies the text of the column label for the SUM statistic in the table of statistics.
specifies a numeric variable for sum or mean calculations.
specifies the chart statistic.

Required Argument

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. Multiple chart variables must be separated with blanks.

Optional Arguments

Options in an HBAR, HBAR3D, VBAR, or VBAR3D statement affect all graphs that are produced by that statement. You can specify as many options as you want and list them in any order. For details about specifying colors, see Using Colors in SAS/GRAPH Programs. For details about specifying images, see Adding Images To SAS/GRAPH Output. For a complete description of the graphics options, see Graphics Options and Device Parameters Dictionary.

ANNOTATE=Annotate-data-set
specifies a data set to annotate all graphs that are produced by the GCHART procedure. To annotate individual graphs, use the ANNOTATE= option in the action statement.
Alias:ANNO=
Note:Annotate coordinate systems 1, 2, 7, and 8 (data system coordinates) are not valid with block, pie, donut, or star charts.
ASCENDING
arranges the bars in ascending order of the value of the chart statistic. By default, bars are arranged in ascending order of midpoint value, without regard to the lengths of the bars. The ASCENDING option reorders the bars from shortest to longest. In horizontal bar charts the ordering is top to bottom; in vertical bar charts the ordering is left to right.
If you also use the GROUP= option, the reordering is performed separately for each group, so the order of the midpoints might be different for each group.
The ASCENDING option overrides any midpoint order specified with the MIDPOINTS= option or specified in the ORDER= option in an AXIS statement assigned to the midpoint axis.
AUTOREF
draws a reference line at each major tick mark on the response axis. To draw reference lines at specific points on the response axis, use the REF= option.
By default, reference lines in two-dimensional bar charts are drawn in front of the bars. To draw reference lines behind the bars, use the CLIPREF option.
By default, reference lines in three-dimensional bar charts are drawn on the back plane of the axis. To draw reference lines in front of the bars, use the FRONTREF option.
AXIS=AXIS<1...99>
CAUTOREF=reference-line-color
specifies the color of reference lines drawn at major tick marks, as determined by the AUTOREF option. If you do not specify the CAUTOREF option, the default color is the value of the CAXIS= option. If neither option is specified, the default color is retrieved from the current style or from the device's color list if the NOGSTYLE option is specified. To specify a line type for these reference lines, use the LAUTOREF= option.
Style reference:Color attribute of the GraphGridLines element
CAXIS=axis-color
specifies a color for the response and midpoint axis lines and for the default axis area frame. If you omit the CAXIS= option, PROC GCHART searches for a color specification in this order:
  1. the COLOR= option in AXIS definitions
  2. the color specified in the current style. However, if the NOGSTYLE option is specified, then the default color is black for the Java and ActiveX devices and the first color in the color list for all other devices.
This option also specifies the default color for all reference lines.
Style reference:Color attribute of the GraphAxisLines attribute
CERROR=error-bar-color
specifies the color of error bars in bar charts. The default is the color of the response axis, which is controlled by the CAXIS= option.
Style reference:Color attribute of the GraphError element
CFRAME=background-color
specifies the color with which to fill the axis area in two-dimensional bar charts or the floor, back wall, and side wall of three-dimensional bar charts. The axis area color does not affect the frame color, which is always the same as the midpoint axis line color and controlled by the CAXIS= option. By default, the axis area in two-dimensional bar charts is not filled.
Alias:CFR=
Style reference:Color attribute of the GraphWalls element
Restriction:CFRAME= is overridden by the NOFRAME and IFRAME= options. If the IFRAME= option is in effect, an image appears in the axis area instead of the color.
Note:If the color of the background, the bar, and the outline are the same, you might not be able to distinguish the bars.

IFRAME=fileref | 'external-file'

CFREQ
displays the cumulative frequency statistic in the table of statistics and above vertical bars. Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values or if the FREQ option is specified.
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device.
Interaction:Specifying the CFREQ option when creating an HBAR chart with an ActiveX device causes the cumulative frequencies to display at the end of each bar instead of the frequencies.

Displaying Statistics in Horizontal Bar Charts

Displaying Statistics in Vertical Bar Charts

CFREQLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the CFREQ statistic in the table of statistics. Column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify CFREQLABEL=NONE.
Restriction:Not supported by Java or ActiveX
CLIPREF
clips the reference lines at the bars. This makes the reference lines appear to be behind the bars. Because the CLIPREF option is the default for three-dimensional bar charts, it affects only two-dimensional charts.
CLM=confidence-level
specifies the confidence intervals to use when drawing error bars. Values for confidence-level must be greater than or equal to 50 and strictly less than 100. The default is 95. See ERRORBAR=BARS | BOTH | TOP for details about how error bars are computed and drawn.
COUTLINE=bar-outline-color | SAME
outlines all bars or bar segments and legend values in the subgroup legend (if it appears) using the specified color. SAME specifies that the outline color of a bar or a bar segment or a legend value is the same as the interior pattern color.
The default outline color depends on the use of the PATTERN statement:
  • If you do not specify a PATTERN statement, the default outline color is the color of the current style.
  • If you specify the NOGSTYLE option and no PATTERN statement, the default outline color is black for the Java or ActiveX devices. Otherwise, the default outline color is the foreground color. If you specify an EMPTY PATTERN statement, then the default outline color is the same as the fill color.
CPERCENT
displays the cumulative percentage statistic in the table of statistics and above vertical bars. Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values or if the FREQ, CFREQ, or PERCENT option is specified.
Alias:CPCT=
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device
Interaction:Specifying the CPERCENT option when creating an HBAR chart with an ActiveX device causes the cumulative percentages to display at the end of each bar instead of the frequencies.

Displaying Statistics in Horizontal Bar Charts

Displaying Statistics in Vertical Bar Charts

CREF=reference-line-color| (reference-line-color) | (reference-line-color-list)
specifies colors for reference lines. Specifying a single color without parentheses applies that color to all reference lines, including lines drawn with the AUTOREF and REF= options. Note that the CAUTOREF= option overrides the CREF= reference color for reference lines drawn with the AUTOREF option. Specifying a single color in parentheses applies that color to only the first reference line drawn with the REF= option. Specifying a reference color list applies colors in sequence to successive lines drawn with the REF= option. The syntax of the color list requires parentheses and color names separated by spaces (color1 color2 ...colorN) or separated by commas (color1, color2 ..., colorN). If you do not specify the CREF= option, the GCHART procedure uses the color specified by the CAXIS= option. If neither option is specified, the default color is retrieved from the current style or from the first color in the color list if the NOGSTYLE option is specified. To specify line types for these reference lines, use the LREF= option.
Alias:CR=
Style reference:LineStyle attribute of the GraphGridLines element
CPERCENTLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the CPERCENT statistic in the table of statistics. Column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify CPERCENTLABEL=NONE.
Restriction:Not supported by Java or ActiveX
CTEXT=text-color
specifies a color for all text on the axes and legend, including axis labels, tick mark values, legend labels, and legend value descriptions. The GCHART procedure searches for a color specification in this order:
  1. colors specified for labels and values on assigned AXIS and LEGEND statements, which override the CTEXT= option specified in the BAR statement.
  2. the color specified by the CTEXT= option in the BAR statement.
  3. the color specified by the CTEXT= option in the GOPTIONS statement.
  4. the color specified in the current style. However, if the NOGSTYLE option is specified, then the default color is black for the Java and ActiveX devices and the first color in the color list for all other devices.
The LEGEND statement's VALUE= color is used for legend values, and its LABEL= color is used for legend labels.
The AXIS statement's VALUE= color is used for axis values, and its LABEL= color is used for axis labels. However, if the AXIS statement specifies only general axis colors with its COLOR= option, the CTEXT= color overrides the general COLOR= specification and is used for axis labels and values. In this instance the COLOR= color is still used for all other axis colors, such as tick marks.
Style reference:Color attributes of the GraphValueText and the GraphLabelText elements
Note:If you use a BY statement in the procedure, the color of the BY variable labels is controlled by the CBY= option in the GOPTIONS statement.
DESCENDING
arranges the bars in descending order of the value of the chart statistic. By default, bars are arranged in ascending order of midpoint value, without regard to the lengths of the bars. The DESCENDING option reorders the bars from longest to shortest. In horizontal bar charts the ordering is top to bottom; in vertical bar charts the ordering is left to right. If you also use the GROUP= option, the reordering is performed separately for each group, so the order of the midpoints might be different for each group.
The DESCENDING option overrides any midpoint order that is specified with the MIDPOINTS= option. The DESCENDING option also overrides any midpoint order that is specified in the ORDER= option in an AXIS statement assigned to the midpoint axis.
DESCRIPTION=“description
specifies a description of the output. The maximum length for description is 256 characters. The description does not appear in the output. The descriptive text is shown in each of the following:
  • the chart description for Web output (depending on the device driver). See Chart Descriptions for Web Presentations for more information.
  • the Table of Contents that is generated when you use the CONTENTS= option on an ODS HTML statement, assuming that the output is generated while the contents page is open.
  • the description and the properties for the output in the Results window.
  • the description and properties for the catalog entry in the SAS Explorer.
  • the Description field of the PROC GREPLAY window.
The description can include the #BYLINE, #BYVAL, and #BYVAR substitution options, which work as they do when used on TITLE, FOOTNOTE, and NOTE statements. Refer to Substituting BY Line Values in a Text String. The 256-character limit applies before the substitution takes place for these options. Thus, if in the SAS program the description text exceeds 256 characters, it is truncated to 256 characters, and then the substitution is performed.
Alias:DES=
Default:BAR CHART OF chart-variable
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 bar 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=number-of-midpoints option is ignored when you use the DISCRETE option. The MIDPOINTS= option overrides the DISCRETE option. The ORDER= option in an AXIS statement that is assigned to the midpoint axis can rearrange or exclude discrete midpoint values.
ERRORBAR=BARS | BOTH | TOP
draws confidence intervals for either of the following:
  • the mean of the SUMVAR= variable for each midpoint if you specify TYPE=MEAN
  • the percentage of observations assigned to each midpoint if you specify TYPE=PCT with no SUMVAR= option
The ERRORBAR= option cannot be used with values of the TYPE= option other than MEAN or PCT. Valid values for the ERRORBAR= option are:
BARS
draws error bars as bars half the width of the main bars.
BOTH
draws error bars as two ticks joined by a line (default).
TOP
draws the error bar as a tick for the upper confidence limit that is joined to the top of the bar by a line.
By default, the ERRORBAR= option uses a confidence level of 95%. You can specify different confidence levels with the CLM= option.
When you use the ERRORBAR= option with TYPE=PCT, the confidence interval is based on a normal approximation. Let TOTAL be the total number of observations, and PCT be the percentage assigned to a given midpoint. The standard error of the percentage is approximated as follows:
APSTDERR=100 * SQRT((PCT/100) * (1–(PCT/100)) / TOTAL);
Let LEVEL be the confidence level specified using the CLM= option, with a default value of 95. The upper confidence limit for the percentage is computed as follows:
UCLP = PCT + APSTDERR * PROBIT( 1-(1-LEVEL/100)/2 );
The lower confidence limit for the percentage is computed as follows:
LCLP = PCT - APSTDERR * PROBIT( 1-(1-LEVEL/100)/2 );
When you use the ERRORBAR= option with TYPE=MEAN, the sum variable must have at least two nonmissing values for each midpoint. Let N be the number of observations assigned to a midpoint, MEAN be the mean of those observations, and STD be the standard deviation of the observations. The standard error of the mean is computed as follows:
STDERR = STD / SQRT(N);
Let LEVEL be the confidence level specified using the CLM= option, with a default value of 95. The upper confidence limit for the mean is computed as follows:
UCLM = MEAN + STDERR * TINV( 1-(1-LEVEL/100)/2, N-1);
The lower confidence limit for the mean is computed as
LCLM = MEAN - STDERR * TINV( 1-(1-LEVEL/100)/2, N-1);
If you want the error bars to represent a given number C of standard errors instead of a confidence interval, and if the number of observations assigned to each midpoint is the same, then you can find the appropriate value for the CLM= option by running a DATA step. For example, suppose you want error bars that represent one standard error (C=1) with a sample size of N. Run the following DATA step to compute the appropriate value for the CLM= option and assign that value to a macro variable &LEVEL:
data _null_; 
c = 1; n = 10; 
level = 100 * (1 - 2 * (1 - probt( c, n-1))); 
put _all_; 
call symput("level",put(level,best12.)); 
run;
Then when you run the GBARLINE procedure, you can specify CLM=&LEVEL.
Note that this trick does not work precisely if different midpoints have different numbers of observations. However, choosing an average value for N can yield sufficiently accurate results for graphical purposes if the sample sizes are large or do not vary much.
If you want to create a chart with a legend and error bars, use the SUBGROUP= option with the ERRORBAR= option, and set the SUBGROUP= option to the midpoint variable.
FRAME | NOFRAME
specifies whether a line is drawn around the axis area of a two-dimensional bar chart or a back wall is drawn in a three-dimensional bar chart. The default is FRAME. Specifying the NOFRAME option removes the axis area frame from two-dimensional charts, including any background color or image. For three-dimensional charts, NOFRAME removes the back wall color or image, and leaves the vertical and horizontal axis planes and axes. To remove these planes, use the NOPLANE option in the AXIS statement. To remove one or more axis elements, use either the AXIS statement or the NOAXIS option.
The color of the frame is the color of the midpoint axis, which is determined by the CAXIS= option.
Alias:FR | NOFR
Restriction: The NOFRAME option overrides the CFRAME= and IFRAME= options and the goption IBACK.

IFRAME=fileref | 'external-file'

FREQ
displays the frequency statistic in the table of statistics and above vertical bars. Non-integer values are rounded down to the nearest integer. Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values. This option overrides the CFREQ, PERCENT, CPERCENT, SUM, and MEAN options.
FREQLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the FREQ statistic in the table of statistics. column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify FREQLABEL=NONE.
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 that is 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. Non-integer values of numeric-variable are truncated to integers. FREQ= is valid with all chart statistics.
Because you cannot use TYPE=PERCENT, TYPE=CPERCENT, TYPE=FREQ, or TYPE=CFREQ with the SUMVAR= option, you must use FREQ= to calculate percentages, cumulative percentages, frequencies, or cumulative frequencies based on a sum.
The statistics are not affected by applying a format to numeric-variable.
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device.
Interaction:When specifying the ACTIVEX device with an HBAR chart, the frequencies are displayed at the end of each bar by default.
FRONTREF
specifies that reference lines drawn by the AUTOREF or REF= options should be drawn in front of the bars. By default, reference lines in three-dimensional bar charts are drawn on the back plane of the axis.
G100
calculates the percentage and cumulative percentage statistics separately for each group. When you use the G100 option, the individual percentages reflect the contribution of the midpoint to the group and total 100% for each group. The G100 option 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% for the entire chart.
GAXIS=AXIS<1...99>
assigns the specified AXIS definition to the group axis. (A group axis is created when you use the GROUP= option.) You can use the AXIS definition to modify the order of the groups, the text of the labels, and appearance of the axis. The GAXIS= option is ignored if the specified AXIS definition does not exist.
The AXIS statement options MAJOR= and MINOR= are ignored in AXIS definitions assigned to the group axis because the axis does not use tick marks. A warning message is written to the SAS log if these options appear in the AXIS definition.
The Java and ActiveX devices do not support all AXIS statement options. See the AXIS Statement for more information.
To remove groups from the chart, use the ORDER= option in the AXIS statement.
To suppress the brackets drawn around the values on the group axis in vertical bar charts, use the NOBRACKETS option in the AXIS statement.
Restriction:Partially supported by Java and ActiveX
GROUP=group-variable
organizes the data according to values of group-variable. Group-variable can be either character or numeric and is always treated as a discrete variable.
The GROUP= option produces a separate group of bars for each unique value of the group variable. Missing values for group-variable are treated as a valid group. The groups are arranged in ascending order of the group variable values.
By default, each group includes all midpoints, even if no observations for the group fall within the midpoint range, meaning that no bar is drawn at the midpoint. Use the NOZERO option to suppress midpoints with no observations.
The GROUP= option also produces a group axis that lists the values that distinguish the groups. The group axis has no axis line but displays up to 256 characters of the group variable name or label. To modify the group axis, assign an AXIS definition with the GAXIS= option.
In horizontal bar charts, the group axis is to the left of the midpoint axis. The groups are arranged from top to bottom, starting with the lowest value at the top.
In vertical bar charts, the group axis is below the midpoint axis and the groups are arranged from left to right starting with the lowest value at the left. If the group label in a vertical bar chart is narrower than all the bars in the group, brackets are added to the label to emphasize which bars belong in each group. Group brackets are not displayed if the space between the group values is less than one and one-half character cells. Use the NOBRACKETS option in the AXIS statement to suppress the group brackets.
GSPACE=group-spacing
specifies the amount of extra space between groups of bars. Group-space can be any nonnegative number. Units are character cells. Use GSPACE=0 to leave no extra space between adjacent groups of bars. In this case, the same space appears between groups of bars as between the bars in the same group.
The GSPACE= option is ignored unless you also use the GROUP= option. By default, the GCHART procedure calculates group spacing based on the size of the axis area and the number of bars in the chart.
HTML=variable
identifies the variable in the input data set whose values create links or data tips or both. The variable values are either links or data tips or both that are created in the HTML file generated by the ODS statement. The links are URLs pointing to Web pages to display when the user clicks (drills down) on elements in the graph. Data tips are detailed information or data values that are displayed as pop-up text when a mouse pointer is positioned over elements in the graph.
HTML_LEGEND=variable
identifies the variable in the input data set whose values create links. Input data set variable values create links that are associated with a legend value and point to the URL to display when the user clicks (drills down) on the value.
Restriction:Not supported by Java or ActiveX
IFRAME=fileref | 'external-file'
identifies the image file that you want to apply to a two-dimensional chart's axis area or a three-dimensional chart's back wall. fileref must be a valid SAS fileref up to eight characters long and must have been previously assigned with a FILENAME statement. external-file must specify the complete filename of the image file that you want to use. The format of external-file varies across operating environments.
Restrictions:Not supported by Java

This option is overridden by the NOIMAGEPRINT goption. For information about the NOIMAGEPRINT goption, see IMAGEPRINT.

See: the goption IBACK to fill the background surrounding two- and three-dimensional bar charts

IMAGESTYLE= TILE | FIT

Displaying Images on Data Elements

CFRAME=background-color

IMAGESTYLE= TILE | FIT
specifies whether to use multiple instances of an image, or stretch a single image. Use multiple instances of an image to fill the axis area or back wall (TILE). You can choose to stretch a single instance of an image to fill the axis area or back wall (FIT).The TILE value is the default.
Restriction:Not supported by Java
INSIDE=statistic
displays the values of the specified statistic inside the bars. For the Java and ActiveX devices, this option is valid for both horizontal and vertical bar charts. For other devices, this option is valid only for vertical bar charts. For subgrouped bar charts generated with the Java and ActiveX devices, you can display only one statistic for each bar. These devices do not create both inside and outside bar labels. For graphs generated with the Java and ActiveX devices, the OUTSIDE= option overrides INSIDE= option.
Statistic can be one of the following:
  • FREQ
  • CFREQ
  • CPERCENT | CPCT
  • MEAN
  • PERCENT | PCT
  • SUM
If the bars are subgrouped, only the following statistics are valid:
  • FREQ
  • PERCENT | PCT
  • SUBPCT
  • SUM
With subgroups, PERCENT displays the percent contribution of each subgroup to the midpoint value of the bar, based on frequency. The PERCENT values for each subgroup total the percent contribution of the bar to the whole. For example, if the percent contribution of the whole bar is 60%, the PERCENT statistic for all the subgroups in that bar are 60% total. To calculate PERCENT based on the SUMVAR= variable, use the FREQ= and TYPE= options. For details, see Calculating Weighted Statistics.
SUBPCT displays the percent contribution of each subgroup to the total bar. The SUBPCT values for each subgroup total the percent contribution to the whole bar. Because of rounding, the total of the percents might not equal 100.
LAUTOREF=reference-line-type
specifies the line type for reference lines at major tick marks, as determined by the AUTOREF option. Line types are specified as whole numbers from 1 to 46, with 1 representing a solid line and the other values representing dashed lines. The default line type is retrieved from the current style, or if the NOGSTYLE option is specified, the default value is 1, which draws a solid line. To specify a color for these reference lines, use the CAUTOREF= option.
Style reference:LineStyle attribute of the GraphGridLines element
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 any of the following is true:
  • The SUBGROUP= option is not used.
  • The specified LEGEND definition is not in effect.
  • The NOLEGEND option is used.
  • The PATTERNID= option is set to any value other than SUBGROUP. That is, the value of PATTERNID= is BY or GROUP or MIDPOINT.
To create a legend based on the chart midpoints instead of the subgroups, use the chart variable as the subgroup variable:
hbar city / subgroup=city;
Restriction:The Java and ActiveX devices do not support all LEGEND statement options.

SUBGROUP=subgroup-variable

LEVELS= number-of-midpoints | ALL
specifies the number of midpoints to be graphed for a chart variable. After you specify the number of midpoints that you want, the range for each midpoint is calculated automatically, using the algorithm in Terrell and Scott (1985).
If you specify LEVELS=ALL, then all unique numeric or character midpoint values are graphed. You might have instances where the data contains a large number of unique midpoint values (more than 200). In this case you can use the XPIXELS and YPIXELS GOPTIONS to enable the device driver to render a larger (and more readable) graph.
The LEVELS=number-of-midpoints option is ignored if any of the following are true:
  • The chart variable is character type.
  • The DISCRETE option is used.
  • The MIDPOINTS= option is used.
LREF=reference-line-type | (reference-line-type) | (reference-line-type-list)
specifies line types for reference lines. Line types are specified as whole numbers from 1 to 46, with 1 representing a solid line and the other values representing dashed lines. Specifying a line type without parentheses applies that type to all reference lines drawn with the AUTOREF and REF= options. Note that the LAUTOREF= option overrides LREF=reference-line-type for reference lines drawn with the AUTOREF option. Specifying a single line type in parentheses applies that line type to the first reference line drawn with the REF= option. Specifying a line type list applies line types in sequence to successive reference lines drawn with the REF= option. The syntax of the line-type list requires parentheses and line types separated by spaces (type1 type2 ...typeN). If you do not specify the LREF= option, the GCHART procedure uses the type specified by the AXIS statement's STYLE= option. If neither option is specified, the default line type is retrieved from the current style. However, if the NOGSTYLE option is specified, the default value is 1, which draws a solid line. To specify colors for these reference lines, use the CREF= option.
Alias:LR=
Style reference:LineStyle attribute of the GraphGridLines element
Restriction:Not supported by Java
MAXIS=AXIS<1...99>
assigns the specified AXIS definition to the midpoint axis. The MAXIS= option is ignored if the specified AXIS definition does not exist.
Restriction:The Java and ActiveX devices do not support all AXIS statement options.

Understanding Midpoints

MEAN
displays the mean statistic in the table of statistics and above vertical bars. By default, the column heading in the table includes the name of the variable for which the mean is calculated. Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values or if the FREQ, CFREQ, PERCENT, CPERCENT, or SUM option is specified. The MEAN option is ignored unless you also use the SUMVAR= option.
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device.
Interaction:Specifying the MEAN option when creating an HBAR chart with an ActiveX device causes the means to display at the end of each bar instead of the frequencies.

Displaying Statistics in Horizontal Bar Charts

Displaying Statistics in Vertical Bar Charts

MEANLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the MEAN statistic in the table of statistics. column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify MEANLABEL=NONE.
Restriction:Not supported by Java and ActiveX
MIDPOINTS=value-list
specifies the midpoint values for the bars. The way you specify value-list depends on the type of the chart variable.
  • For numeric chart variables, value-list is either an explicit list of values, or a starting and an ending value with an interval increment, or a combination of both forms:
    • n <...n>
    • n TO n <BY increment>
    • n<...n> TO n <BY increment> <n <...n>>
    If a numeric variable has an associated format, the specified values must be the unformatted values.
    If you omit the DISCRETE option, then numeric values are treated as continuous, which means that the following is true by default:
    • The lowest midpoint consolidates all data points from negative infinity to the median of the first two midpoints.
    • The highest midpoint consolidates all data points from the median of the last two midpoints up to infinity.
    • All other values in value-list specify the median of a range of values, and the GCHART procedure calculates the midpoint values.
    If you include the DISCRETE option, then each value in value-list specifies a unique numeric value.
  • For character chart variables, value-list is a list of unique character values enclosed in quotation marks and separated by blanks:
    'value-1' <...'value-n'>
    If a character variable has an associated format, the specified values must be the formatted values.
    You are able to specify up to 256 characters for each variable value.
For a complete description of value-list, see ORDER=(value-list ) in the AXIS statement.
If the value-list for either type of variable specifies so many midpoints that the axis values overwrite each other, the values might be unreadable. In this case the procedure writes a warning to the SAS log. On many devices, this problem can be corrected by adjusting the size of the text with the HTEXT= graphics option. You can also correct the problem by increasing the number of cells in your graphics display using the HPOS= and VPOS= graphics options.
The ORDER= option in the AXIS statement overrides the order specified in the MIDPOINTS= option. The bar chart statement options ASCENDING and DESCENDING also override both the MIDPOINTS= and ORDER= options in the AXIS statement.
Note:Any character bar variable value with a long text string has the potential to cause a scaling issue and might produce a wider bar chart than desired.
MIDPOINTS=OLD
generates default midpoints using the Nelder algorithm (Applied Statistics 25:94–7, 1976). The MIDPOINTS=OLD option is ignored unless the chart variable is numeric.
MINOR=number-of-minor-ticks
specifies the number of minor tick marks between each major tick mark on the response axis. The MINOR= option in a bar chart statement overrides the number of minor tick marks specified in the MINOR= option in an AXIS definition. The AXIS definition is assigned to the response axis with the RAXIS= option.
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 group and subgroup variables.
NAME='entry-name'
specifies the name of the GRSEG catalog entry and the name of the graphics output file, if one is created. The name can be up to 256 characters long, but the GRSEG name is truncated to eight characters. Uppercase characters are converted to lowercase, and periods are converted to underscores. The default name is GCHART. If the name duplicates an existing name, then SAS/GRAPH adds a number to the name to create a unique name-for example, GCHART1.
If the name specified is exactly eight characters long, then the last character of the image output filename is replaced with a number. For example, myimages is changed to myimage1.
NOAXIS
suppresses all axes, including axis lines, axis labels, axis values, and all major and minor tick marks. If you specify an axis definition with the GAXIS, MAXIS=, or RAXIS= options, then the axes are generated as defined in the AXIS statement. But in this case all lines, labels, values, and tick marks are suppressed. Therefore, AXIS statement options such as ORDER=, LENGTH, and OFFSET= are still used.
To remove only selected axis elements such as lines, values or labels, use specific AXIS statement options.
The NOAXIS option does not suppress either the default frame or an axis area fill requested by the CFRAME= option. To remove the frame around the two-dimensional axis area or the three-dimensional back wall, use the NOFRAME option in the procedure. To remove the horizontal or vertical axis planes, use the NOPLANE option in the AXIS statement.
NOBASEREF
suppresses the zero reference line when the SUM or MEAN chart statistic has negative values.
NOLEGEND
suppresses the legend that is automatically generated by the SUBGROUP= option.
Alias:NOSYMBOL
Interaction:The NOLEGEND option is ignored if the SUBGROUP= option is not used.
NOSTATS (HBAR and HBAR3D only)
suppresses the table of statistics. The NOSTATS option suppresses both the default statistics and specific statistics requested by the FREQ, CFREQ, PERCENT, CPERCENT, SUM, and MEAN options.
Restriction:Not supported by Java
NOSYMBOL
suppresses the legend that is automatically generated by the SUBGROUP= option.
Alias:NOLEGEND
Interaction:The NOSYMBOL option is ignored if the SUBGROUP= option is not used.
NOZERO
suppresses any midpoints for which there are no corresponding values of the chart variable and, hence, no bar. The NOZERO option is typically used with the GROUP= option. This combination suppresses midpoints when not all values of the chart variable are present for every group or if the chart statistic for the bar is 0.
Note:There are instances when a bar is omitted and bar labels are specified with the VALUE= option in an AXIS statement. This might result in the labels being shifted and not displaying with the correct bar.
OUTSIDE=statistic
displays the values of the specified statistic above the bars. For example, OUTSIDE=PERCENT displays the percentages of observations having a given value for the chart variable. For the Java and ActiveX devices, this option is valid for both horizontal and vertical bar charts. For other devices, this option is valid only for vertical bar charts. For subgrouped bar charts generated with the Java and ActiveX devices, you can display only one statistic for each bar. These devices do not create both inside and outside bar labels. For graphs generated with the Java and ActiveX devices, the OUTSIDE= option overrides the INSIDE= option.
Statistic can be one of the following:
  • FREQ
  • CFREQ
  • PERCENT | PCT
  • CPERCENT | CPCT
  • SUM
  • MEAN
PATTERNID=BY | GROUP | MIDPOINT | SUBGROUP
specifies how 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 bars 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 bars in each group 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 bars must be subdivided by the SUBGROUP= option for the SUBGROUP value to have an effect. Without the SUBGROUP= option, all bars have the same pattern.
Note:If you use the SUBGROUP= option and specify a PATTERNID= value other than SUBGROUP, the bar segments use the same pattern and are indistinguishable.
PERCENT
prints the percentages of observations having a given value for the chart variable in the table of statistics and above vertical bars. If a chart variable is not specified, percentages are calculated from the weighted contribution of each observation (frequency). Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values or if the FREQ or CFREQ option is specified.
Alias:PCT=
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device.
Interaction:Specifying the PERCENT option when creating an HBAR chart with an ActiveX device causes the percentages to display at the end of each bar instead of the frequencies.

Displaying Statistics in Horizontal Bar Charts

Displaying Statistics in Vertical Bar Charts

PERCENTLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the PERCENT statistic in the table of statistics. column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify PERCENTLABEL=NONE.
Restriction:Not supported by Java and ActiveX
PERCENTSUM
calculates a percent of the sum variable for horizontal bar charts. The PERCENTSUM option is ignored if the SUMVAR= option is not specified.
RANGE
displays on the axis of the chart the range of numeric values represented by each bar. In the graphics output:
  • The starting value of each range is indicated with the less-than symbol (<).
  • The ending value is indicated with the greater-than-or-equal-to symbol (>=).
  • The default midpoint axis label is “chart-variable RANGE.”
The RANGE option has no effect on axes that represent character data. By default, the values shown on the axis are determined by the value of the MIDPOINTS=value-list.
Interactions: If specified, the DISCRETE option overrides the RANGE option.

During the creation of vertical bar charts, when options RANGE and LEVELS= are both used, RANGE displays the endpoints of the range for each vertical bar. It displays this rather than just the numerical midpoint of the range as would be displayed with the LEVELS= option alone. If necessary, RANGE automatically angles or rotates the values and they might be less readable.

If the RANGE, LEVELS=, and AXIS VALUE= options are all specified, the RANGE option is ignored and the LEVELS= option displays the numeric midpoint of each vertical bar.

RAXIS=value-list | AXIS<1...99>
AXIS=value-list | AXIS<1...99>
specifies values for the major tick mark divisions on the response axis or assigns the specified AXIS definition to the axis. See the MIDPOINTS=value-list for a description of value-list. By default, the GCHART procedure scales the response axis automatically and provides an appropriate number of tick marks.
You can specify negative values. But note that negative values are reasonable only when TYPE=SUM or TYPE=MEAN and one or more of the sums or means are less than 0. Frequency and percentage values are never less than 0.
For lists of values, a separate major tick mark is created for each individual value. A warning message is written to the SAS log if the values are not evenly spaced.
If the values represented by the bars are larger than the highest tick mark value, the bars are truncated at the highest tick mark.
If you use a BY statement with the PROC GCHART statement, then the same response axes are produced for each BY group when RAXIS=value-list is used. The same is true if there is an ORDER= list in the AXIS statement assigned to the response axis.
Restriction:The Java and ActiveX devices do not support all AXIS statement options.
See: the AXIS Statement for more information.
REF=value | (value) | (value-list)
draws reference lines at the specified points on the response axis. See the MIDPOINTS=value-list for a description of value-list.
Values can be listed in any order, but should be within the range of values represented by the response axis. A warning is written to the SAS log if any of the points are off of the axis, and no reference line is drawn for such points. You can use the AUTOREF option to draw reference lines automatically at all of the major tick marks.
By default, reference lines in three-dimensional bar charts are drawn on the back plane of the axis. To draw the reference lines in front of the bars, use the FRONTREF option.
SHAPE=three-dimensional-bar-shape (HBAR3D and VBAR3D only)
specifies the shape of the bars in charts that are produced with the HBAR3D and VBAR3D statements. three-dimensional-bar-shape can be one of the following:
  • BLOCK | B (the default)
  • CYLINDER | C
  • HEXAGON | H
  • PRISM | P
  • STAR | S
SPACE=bar-spacing
specifies the amount of space between individual bars or between the bars within each group if you also use the GROUP= option. Bar-spacing can be any nonnegative number, including decimal values. Units are character cells. You cannot specify a unit of measure, such as inches or percent. By default, the GCHART procedure calculates spacing based on the size of the axis area and the width of the bars on the chart. Use SPACE=0 to leave no space between adjacent bars.
The SPACE= option is ignored if the following is true:
  • You specify the WIDTH= option and are using the Java or ActiveX devices.
  • The specified spacing requests a chart that is too large to fit in the space available for the midpoint axis. In this case, a warning message is issued.
SUBGROUP=subgroup-variable
divides the bars 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 bar 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 that provides 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.
SUBOUTSIDE=statistic (VBAR and VBAR3D only)
displays a list of the subgroup values of the specified statistic above the bars. The values are listed vertically above each bar in the order in which they occur on the bar from the top down. This option is valid for VBAR and VBAR3D charts only. The Java and ActiveX devices do not support this option. For all of the other devices:
  • SUBOUTSIDE= overrides OUTSIDE=.
  • If you specify both the INSIDE= and SUBOUTSIDE= options, use the same statistic for both. If you specify a different statistic for the SUBOUTSIDE= option, SAS/GRAPH uses the INSIDE= statistic for SUBOUTSIDE= instead.
Statistic can be one of the following:
  • FREQ
  • CFREQ
  • PERCENT | PCT
  • CPERCENT | CPCT
  • SUM
Restriction:Not supported by Java and ActiveX

Displaying Statistics in Vertical Bar Charts

SUM
displays the sum statistic in the table of statistics and above vertical bars. By default, the column heading in the table includes the name of the variable for which the sum is calculated. Default statistics are suppressed when you request specific statistics. For vertical bar charts, this option is ignored if the bars are too narrow to avoid overlapping values or if the FREQ, CFREQ, PERCENT, or CPERCENT option is specified. SUM is ignored unless you also use the SUMVAR= option.
Restriction:The table of statistic values is not printed when creating an HBAR chart with an ActiveX device.
Interaction:Specifying the SUM option when creating an HBAR chart with an ActiveX device causes the sums to display at the end of each bar instead of the frequencies.

Displaying Statistics in Horizontal Bar Charts

Displaying Statistics in Vertical Bar Charts

SUMLABEL='column-label' | NONE (HBAR and HBAR3D only)
specifies the text of the column label for the SUM statistic in the table of statistics. Column-label can be up to 32 characters long, but a single line of the label can be no more than 24 characters. By default, a label with more than one word breaks as close to the center of the line as possible. A double space in the string forces a line break. To suppress the label, specify SUMLABEL=NONE.
Restriction:Not supported by Java and ActiveX
SUMVAR=numeric-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 length of the bars along the response axis, and they are displayed at major tick marks.
When you use the SUMVAR= option, the TYPE= option must be either SUM or MEAN. With the SUMVAR= option, the default is TYPE=SUM.
TYPE=statistic
specifies the chart statistic.
  • If the SUMVAR= option is not used, statistic can be one of the following:
    FREQ
    frequency (the default)
    CFREQ
    cumulative frequency
    PERCENT PCT
    percentage
    CPERCENT CPCT
    cumulative percentage
  • If the SUMVAR= option is used, statistic can be either of the following:
    SUM
    sum (the default)
    MEAN
    mean
You cannot use TYPE=FREQ, TYPE=CFREQ, TYPE=PERCENT, or TYPE=CPERCENT with the SUMVAR= option. Therefore, you must use the FREQ= option 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 or length of the bar represents the mean for the entire midpoint. The subgroup segments are proportional to the subgroup's contribution to the sum for the bar. See also the option description for SUBGROUP=subgroup-variable.
See:About Chart Statistics for a complete description of statistic types
URL=character-variable
specifies a character variable whose values are URLs. The variable values are URLs for Web pages to display when the user clicks (drills down) on elements in the graph.
Restriction: This option affects graphics output that is created through the ODS HTML destination only.
Interaction:If you specify both the HTML= and the URL= options, then the URL= option is ignored.

Example: GIF Output with Drill-Down Links

WAUTOREF=reference-line-width
specifies the line width for reference lines at major tick marks, as determined by the AUTOREF option. Line widths are specified as whole numbers. The default line width is specified by the current style or by the AXIS statement's WIDTH= option. (By default, WIDTH=1.) To specify a color for these reference lines, use the CAUTOREF= option.
Style reference:LineThickness attribute of the GraphGridLines element
WIDTH=bar-width
specifies the width of the bars. By default, the GCHART procedure selects a bar width that accommodates the midpoint values displayed on the midpoint axis using a hardware font and a height of one cell. Units for bar-width are character cells. The value for bar-width must be greater than 0, but it does not have to be an integer, for example:
vbar site / width=1.5;
If the requested bar width results in a chart that is too large to fit in the space available for the midpoint axis, then the procedure issues a warning in the log and ignores the WIDTH= option. If the specified width is too narrow, the procedure displays the midpoint values vertically.
WOUTLINE=bar-outline-width
specifies the width of the outline in pixels. The WOUTLINE= option affects both the bar and the subgroup outlines.
Style reference:LineThickness attribute of the GraphOutlines element
Restriction:Not supported by Java
WREF=reference-line-width | (reference-line-width) | (reference-line-width-list)
specifies line widths for reference lines. Line widths are specified as whole numbers. Specifying a line width without parentheses applies that type to all reference lines drawn with the AUTOREF and REF= options. Note that the WAUTOREF= option overrides WREF=reference-line-width for reference lines drawn with the AUTOREF option. Specifying a single line width in parentheses applies that line width to the first reference line drawn with the REF= option. Specifying a line width list applies line widths in sequence to successive reference lines drawn with the REF= option. The syntax of the line-width list requires parentheses and line widths separated by spaces (width1 width2 ...widthN). The default line width is specified by the current style or by the AXIS statement's WIDTH= option. (By default, WIDTH=1.) To specify colors for these reference lines, use the CREF= option.
Style reference:LineThickness attribute of the GraphReference element
Restriction:Not supported by Java

Details

Description

The HBAR, HBAR3D, VBAR, and VBAR3D statements specify the variable or variables that define the categories of data to chart. These statements automatically do the following:
  • determine the midpoints.
  • calculate the chart statistic for each midpoint (the default is FREQ).
  • scale the response axis and the bars according to the statistic value.
  • determine bar width and spacing.
  • assign patterns to the bars; the default bar or block pattern is SOLID.
  • draw a frame around the axis area using a color determined by the current style. Or, if the NOGSTYLE option is specified, use the first color in the device's color list
You can use statement options to do the following:
  • select or order the midpoints (bars)
  • control the tick marks on the response axis
  • change the type of chart statistic
  • display specific statistics
  • modify the appearance of the chart.
You can also specify additional variables by which to group, subgroup, or sum the data.
All bar charts allow grouping, which uses an additional category to organize the bars into groups, and subgrouping, which divides the bars into segments.
In addition, you can do the following:

The Chart Statistic and the Response Axis

Where Chart Statistic Values Are Displayed

In bar charts, the scale of values of the chart statistic is displayed on the response axis. By default, the response axis is divided into evenly spaced intervals identified with major tick marks that are labeled with the corresponding statistic value. Minor tick marks are evenly distributed between the major tick marks unless a log axis has been requested. For sum and mean statistics, the major tick marks are labeled with values of the SUMVAR= variable (formatted if the variable has an associated format). The response axis is also labeled with the statistic type.

Specifying Logarithmic Axes

Logarithmic axes can be specified with the AXIS statement. See the AXIS Statement for a complete discussion.

Displaying Statistics in Horizontal Bar Charts

Details

For graphs generated with the Java and ActiveX devices, default statistics are not generated, but you can display one statistic at the end of each bar. To specify the statistic, specify the FREQ, CFREQ, PERCENT, CPERCENT, PERCENTSUM, SUM, or MEAN option.
For graphs generated with other devices, the HBAR and HBAR3D statements print a table of statistic values to the right of the bars. When the value of TYPE= is FREQ, CFREQ, PERCENT, or CPERCENT, the frequency, cumulative frequency, percentage, and cumulative percentage statistics are printed next to the bars by default. When TYPE=SUM, the frequency and sum statistic values are printed by default. When TYPE=MEAN, the frequency and mean statistic values are printed by default. However, if you use the FREQ, CFREQ, PERCENT, CPERCENT, PERCENTSUM, SUM, or MEAN options to request specific statistics, the default statistics are not printed.
For sum and mean, the name of the SUMVAR= variable is added to the heading for the column of values.

Specifying the Table of Statistics

You can use the FREQ, CFREQ, PERCENT, CPERCENT, PERCENTSUM, SUM, and MEAN options to select only certain statistics. Without the SUMVAR= option, only the frequency, cumulative frequency, percentage, and cumulative percentage statistics can be printed. With the SUMVAR= option, all statistics, including the sum and mean, can be printed. You can suppress all statistics with the NOSTATS option.
To change the column labels for any statistic in the table, use one or more of the statistic column label options: FREQLABEL=, CFREQLABEL=, PERCENTLABEL=, CPERCENTLABEL=, SUMLABEL=, and MEANLABEL=.
To control the font and size of the text in the table of statistics, use the graphics options FTEXT and HTEXT.

Displaying Statistics in Vertical Bar Charts

Statistic values on vertical bar charts are not printed by default. You must explicitly request a statistic with the FREQ, CFREQ, PERCENT, CPERCENT, SUM, MEAN, INSIDE=, OUTSIDE=, or SUBOUTSIDE= option.
For graphs generated with the Java and ActiveX devices, you can display one statistic for each bar. For graphs generated with other devices, you can display up to two statistics. Statistics can be displayed either above the bars or inside the bars.
To specify a statistic that you want to display above the bars, specify the statistic option (FREQ, CFREQ, PERCENT, CPERCENT, SUM, or MEAN) or specify OUTSIDE=statistic. When subgrouping is used, to display a list of the subgroup statistics above each bar, specify SUBOUTSIDE=statistic. To specify a statistic that you want to display inside the bars, specify INSIDE=statistic.
For graphs generated with the Java and ActiveX devices, the OUTSIDE= option overrides INSIDE=, and INSIDE= overrides the FREQ, CFREQ, PERCENT, CPERCENT, SUM, and MEAN options. For graphs generated with other devices, the individual statistic options and the SUBOUTSIDE= option override the OUTSIDE= option.
If more than one statistic option is specified, only the highest priority statistic is displayed. The priority order, from highest to lowest, is as follows:
  1. FREQ
  2. CFREQ
  3. PERCENT
  4. CPERCENT
  5. PERCENTSUM
  6. SUM
  7. MEAN
The bars must be wide enough to accommodate the text. You can adjust the width of the bars with the WIDTH= option. To control the font and size of the text, use the graphics options FTEXT and HTEXT.

Ordering and Selecting Midpoints

To rearrange character or discrete numeric midpoint values or to select ranges for numeric values, use the MIDPOINTS= option. Remember that although changing the number of midpoints for numeric variables can change the range of values for individual midpoints, it does not change the range of values for the chart as a whole. For details see Understanding Midpoints.
Like the MIDPOINTS= option, the ORDER= option in the AXIS statement can rearrange the order of the midpoints or suppress the display of discrete numeric or character values. However, the ORDER= option cannot calculate the midpoints for a continuous numeric variable, or exclude values from the calculations. For details, see the description of the value-list in the AXIS statement.

Controlling Bar Chart Patterns, Colors, and Images

Default Patterns and Outlines

Each bar in a bar chart is filled with a pattern. Because the system option, GSTYLE, is in effect by default, the procedure uses the style's default patterns and outlines when producing output. By default, the procedure does the following:
  • fills the bars with bar patterns, beginning with the default fill, SOLID, and rotates it through the list of colors available in the default style. When these colors are exhausted, the procedure a slightly modified version of the original color list. It continues in this fashion until each of the chart variables have been assigned a unique pattern.
    If you use the default style colors and the first color in the list is either black or white, then the procedure does not create a pattern in that color. If you specify a color list with the COLORS= graphics option, the procedure uses all the colors in the list to generate the patterns.
  • outlines bars and bar segments using the color defined by the style.
See About Patterns for more information about how the GCHART procedure assigns default patterns and outlines.

User-Defined Patterns

To override the default patterns and select fills and colors for the bars or bar segments, use the PATTERN statement. Only bar or block patterns are valid; all other pattern fills are ignored. For a complete description of all bar or block patterns, see VALUE=bar/block-pattern in the PATTERN statement.
Whenever you use PATTERN statements, the default pattern outline color is that of the current style. Only when the EMPTY pattern is used does the pattern change to SAME. That is, the outline color is the same as the fill color. To specify the outline color, use COUTLINE=bar-outline-color | SAME.

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 bars, the pattern automatically changes each time the subgroup value changes. Also, each subdivision of the bar displays a different pattern. As a result, the number of values for the SUBGROUP= variable determines the number of bar patterns on the chart. If you do not subdivide the bars, all bars 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 description for option PATTERNID=BY | GROUP | MIDPOINT | SUBGROUP for details.

Axis Color

By default, axis elements use the colors specified in the current style or the colors that are specified by AXIS statement color options. However, action statement options can also control the color of the axis lines, text, and frame.
To change the color of...
Use this option...
the axis text
CTEXT=
the axis lines
CAXIS=
the area within the frame
CFRAME=

Adding Images to Bar Charts

You can apply images to the bars and to the axis area of two-dimensional bar charts developed with the HBAR and VBAR statements. In three–dimensional bar charts, you can apply images to the back wall, and to the bars when using certain interactive devices. For details, see Adding Images To SAS/GRAPH Output.