GAREABAR Procedure

HBAR, HBAR3D, VBAR, and VBAR3D Statement

Create horizontal or vertical bar charts in which the length or height of the bar represents the value of a chart statistic for each category of data. A second statistic is represented by the width of each bar.
Requirement: You must specify at least one chart variable, one width variable, and the SUMVAR= option.
Global statements: FOOTNOTE, GOPTIONS, LEGEND, PATTERN, TITLE

Syntax

HBAR | HBAR3D | VBAR | VBAR3D chart-variable*width-variable /
SUMVAR=numeric-variable<options>;

Summary of Optional Arguments

Appearance options
specifies a background color for the graph.
outlines all of the bars with the color specified.
specifies a color for all text on the chart.
specifies whether the two-dimensional axis area frame or the three-dimensional backplane is drawn.
assigns the specified LEGEND definition to the legend generated by the SUBGROUP= option.
suppresses the legend that is automatically generated by the SUBGROUP= option.
Catalog entry description options
specifies the description of the plot.
specifies the name of the graphics output file.
Midpoint options
specifies that the graph data be treated as continuous.
treats the chart variable axis data as discrete data.
divides the bars into segments according to the values of the subgroup-variable column.
Statistic options
specifies the statistic to be applied to the width-variable.

Required Arguments

chart-variable
specifies the variable that defines the categories of data to chart. This variable can be either character or numeric. Each unique value of the chart variable results in a separate bar.
width-variable
specifies the variable that defines the width of each bar. The width-variable is always numeric. The width of each bar represents the sum of the width-variable values for that category. The default statistic is sum.
SUMVAR=numeric-variable
specifies the numeric variable used for statistical calculations. The resulting statistics are represented by the height of each vertical bar or length of each horizontal bar. The default statistic is sum.

Optional Arguments

The options in an HBAR, HBAR3D, VBAR, and VBAR3D statement affect all bars that are produced by the statement. You can specify as many options as you want and list them in any order.

CFRAME=background-color
specifies a background color for the graph. The specified color must be a valid SAS/GRAPH color name.
Alias:CFR=
Style reference:Color attribute of the GraphBackground element
Restriction:Not supported by Java
CONTINUOUS
specifies that the graph data be treated as continuous. Continuous data can take any of an infinite number of values between whole numbers, and so might not be measured accurately. The default is discrete.
Restriction:Not supported by Java
COUTLINE=bar-outline-color | SAME
outlines all of the bars with the color specified. SAME specifies that the outline color of a bar is the same as the interior pattern color. The default color is the outline color of the current style.
Alias:CO=
Style reference:Color attribute of the GraphOutlines element
Restriction:Not supported by Java
CTEXT=text-color
specifies a color for all text on the chart. The GAREABAR procedure looks for the text color in the following order:
  1. colors specified for labels and values on assigned LEGEND statements, which override the CTEXT= option specified in the GAREABAR statement
  2. the color specified by the CTEXT= option in the GAREABAR statement
  3. the color specified by the CTEXT= option in a GOPTIONS statement
  4. the color specified in the current style
Alias:CT=
Style reference:Color attribute of the GraphLabelText and GraphValueText elements
Restriction:Not supported by Java
DESCRIPTION=“description
specifies the description of the plot. The maximum length for description is 256 characters. The description does not appear in the output. The descriptive text is displayed as follows:
  • 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 statements such as TITLE, FOOTNOTE, and NOTE. 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:GAREABAR of chart-variable
Restriction:Not supported by Java
DISCRETE
treats the chart variable axis data as discrete data. Discrete data is characterized as data in which the variable can take only one of a finite set of values. The GAREABAR procedure creates 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 unique value. The default is discrete.
Restriction:Not supported by Java
FRAME | NOFRAME
specifies whether the two-dimensional axis area frame or the three-dimensional backplane is drawn. The default is FRAME, which draws a frame around the axis areas (in two-dimensional bar charts) or generates a colored three-dimensional backplane (in three-dimensional bar charts). For three-dimensional charts, NOFRAME removes the backplane color, and leaves the backplane grid, the vertical axis and plane, and the horizontal axis and plane.
The NOFRAME option overrides the CFRAME= option.
Alias:FR | NOFR
Restriction:Not supported by Java
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 are true:
  • The SUBGROUP= option is not used.
  • The specified LEGEND definition is not in effect.
  • The NOLEGEND option is used.
Restrictions:The LEGEND statement options are partially supported by ActiveX.

Not supported by Java

NAME=“name”
specifies the name of the graphics output file. The name can be up to 256 characters long. Uppercase characters are converted to lowercase. The default name is graph.png. If the name duplicates and existing name, then SAS/GRAPH adds a number to the name to create a unique name, for example, graph1.png.
Restriction:Not supported by Java
NOLEGEND
suppresses the legend that is automatically generated by the SUBGROUP= option. The NOLEGEND option is ignored if the SUBGROUP= option is not used.
Restriction:Not supported by Java
SUBGROUP=subgroup-variable
divides the bars into segments according to the values of the subgroup-variable column. The subgroup-variable column can be either character or numeric, and is always treated as a discrete variable. The SUBGROUP= option creates a separate segment within each bar for each unique value of the subgroup variable.
Restriction:Not supported by Java
WIDTHSTAT= FIRST | LAST | SUM | PCT | PERCENT
specifies the statistic to be applied to the width-variable. Values for WIDTHSTAT= are as follows:
FIRST specifies that the width of each bar is determined solely by the value of the first observation of the width-variable in the data for that bar.
LAST specifies that the width of each bar is determined solely by the value of the last observation of the width-variable in the data for that bar.
SUM specifies that the width of each bar is the sum of the values of the width-variable for that bar.
PCT | PERCENT specifies that the width of each bar is the sum of the values of the width-variable for that bar. The width is expressed as a percentage of the sum of the values of the width-variable for all of the bars.
Alias:WSTAT=
Default:SUM
Restriction:Not supported by Java

Details

The HBAR, HBAR3D, VBAR, and VBAR3D statements specify the variables that define the categories, and width of each bar. The SUMVAR= option variable calculates the length or height of each bar. These statements do the following;
  • calculate the chart statistic for each bar (the default is SUM)
  • scale the response axes and the bars according to the statistic value
  • calculate the width of each bar, based on the value of the width variable
  • draw a frame around the axis area using a color determined by the current style
You can use statement options to change the type of chart, to display specific statistics, and to modify the appearance of the chart. You can also specify an additional variable to subgroup your data, which divides the bars into segments and displays a legend to identify the segments.
In addition, you can make the following changes with global statements:
  • use the LEGEND statement to modify the legend
  • use the TITLE and FOOTNOTE statements to add titles and footnotes to the chart
  • use the PATTERN statement to create PATTERN definitions that define the color and type of area fill for patterns used in graphs.