Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program:
Example Histogram

Example Program

proc template;
  define statgraph histogramparm;
    begingraph;
      entrytitle "Histogram of Vehicle Weights";
      layout overlay;
        histogramparm  x=midpoint y=frequency;
      endlayout;
    endgraph;
  end;
run;

data bins;
  input Midpoint Frequency;
  label midpoint="Vehicle Weight (LBS)";
datalines;
2000 18
3000 208
4000 159
5000 36
6000 6
7000 1
;
run; 

proc sgrender data=bins template=histogramparm;
run;

Statement Summary

When a curve is overlaid on the histogram, the histogram bin width is used to scale the curve so that the area under the curve is equal to the area of the histogram.

Required Arguments

X=numeric-column | expression
specifies the column for the midpoint values.
Requirement: The X values must be uniformly spaced.
Y=non-negative-numeric-column | expression
specifies the column for the frequency values. These values can be frequency counts, percentages, or proportions between 0 and 1.
Requirement: The Y values cannot be negative.

Options

Statement Option
Description
Specifies whether to use bins as the basis for axis tick marks.
Specifies a column for bar labels.
Specifies the color and font attributes of the bar labels.
Specifies the degree of the transparency of the bars.
Specifies whether to display outlined bars, filled bars, or outlined and filled bars.
Specifies whether axis ticks and value labels are drawn at the endpoints of the bins or the midpoints of the bins.
Specifies the appearance of the interior fill area of the bars.
Specifies a label for a legend.
Assigns a name to a plot statement for reference in other template statements.
Specifies the orientation of the Y axis and the bars.
Specifies the properties of the bar outlines.
Specifies that the data columns for this plot be used for determining default axis features.
Specifies user-defined roles that can be used to display information in the tooltips.
Specifies the information to display when the cursor is positioned over a histogram bin.
Specifies display formats for tip columns.
Specifies display labels for tip columns.
Specifies whether data are mapped to the primary X (bottom) axis or the secondary X2 (top) axis.
Specifies whether the X values represent midpoints, lower endpoints, or upper endpoints of the bins.
Specifies whether data are mapped to the primary Y (left) axis or the secondary Y2 (right) axis.
BINAXIS=boolean
Specifies whether to use bins as the basis for axis tick marks.
Default: TRUE
FALSE
The ENDLABELS= option is ignored. A standard axis is used, ignoring bin boundaries and midpoints.
TRUE
The ENDLABELS= option determines how the axis ticks and value labels are displayed.
Interaction: When this option is set to TRUE, some X-axis options that are set on the parent layout might not apply, such as TICKVALUELIST= and TICKVALUESEQUENCE=.
Interaction: This option is ignored if this HISTOGRAMPARM is not the primary plot (for more information about primary plots, see When Plots Share Data and a Common Axis).
DATALABEL= column | expression
specifies a column for the bar labels. The labels appear at the top or end of each bar, depending on the chart orientation.
Note: This feature is for the second maintenance release of SAS 9.3 and later. See What's New in the SAS 9.3 Graph Template Language.
Default: No data labels are displayed.
DATALABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the bar labels. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Note: This feature is for the second maintenance release of SAS 9.3 and later. See What's New in the SAS 9.3 Graph Template Language.
Default: The GraphDataText style element.
Interaction: The DATALABEL= option must be specified for this option to have any effect.
Interaction: When text options are specified, any font properties that are not specified (color, family, size, weight, and style) are derived from the GraphDataText style element.
DATATRANSPARENCY= number
specifies the degree of the transparency of the bars (outline and fill).
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Tip: The FILLATTRS= option can be used to set transparency for just the bar fills. You can combine this option with FILLATTRS= to set one transparency for the bar outlines but a different transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISPLAY=STANDARD | ALL | (display-options)
specifies whether to display outlined bars, filled bars, or outlined and filled bars.
Default: The GraphHistogram:DisplayOpts style reference.
STANDARD
displays outlined, filled bars
ALL
displays outlined, filled bars
(display-options)
a list of comma-separated options enclosed in parentheses. Any of the options from the OUTLINEATTRS= and FILLATTRS= options can be used. The specified list must include one of the following:
OUTLINE—displays outlined bars
FILL—displays filled bars
Use the OUTLINEATTRS= and FILLATTRS= options to control the appearance of the bars.
ENDLABELS=boolean
specifies whether axis ticks and value labels are drawn at the endpoints of the bins or midpoints of the bins.
TRUE draws the axis ticks and value labels at the bin endpoints
FALSE draws the axis ticks and value labels at the bin midpoints
Default: FALSE
Interaction: If BINAXIS= FALSE or this HISTOGRAMPARM is not the primary plot, then this option is ignored.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the interior fill area of the bars. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: The GraphDataDefault style element
Interaction: For this option to have any effect, the fill must be enabled by the ODS style or the DISPLAY= option.
Tip: The DATATRANSPARENCY= option sets the transparency for bar fills and bar outlines. You can combine this option with DATATRANSPARENCY= to set one transparency for the outlines but a different transparency for the fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
LEGENDLABEL= "string"
specifies a label for the legend item that is associated with this plot.
Default: The string specified on the NAME= option.
Restriction: This option applies only to an associated DISCRETELEGEND statement.
NAME= "string"
assigns a name to a plot statement for reference in other template statements.
Default: no default
Restriction: The string is case sensitive, cannot contain spaces, and must define a unique name within the template.
Interaction: The string is used as the default legend label if the LEGENDLABEL= option is not used.
The specified name is used primarily in legend statements to coordinate the use of colors and line patterns between the graph and the legend.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
Default: VERTICAL
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the line properties of the bar outlines. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphOutlines style element.
Interaction: For this option to have any effect, the outlines must be enabled by the ODS style or the DISPLAY= option.
PRIMARY=boolean
specifies that the data columns for this plot be used for determining default axis features.
Default: FALSE
Restriction: This option is ignored if the plot is placed under a GRIDDED or LATTICE layout block.
Details: This option is needed only when two or more plots within an overlay-type layout contribute to a common axis. For more information, see When Plots Share Data and a Common Axis.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the tooltips.
Default: no user-defined roles
(role-name-list)
a blank-separated list of rolename = column pairs.
For example, ROLENAME= (TIP1=PCT) assigns the column PCT to the user-defined role TIP1.
Requirement: The role names that you choose must be unique and different from the pre-defined roles X, Y, and DATALABEL.
This option provides a way to add to the data columns that appear in tooltips specified by the TIP= option.
TIP=(role-list)
specifies the information to display when the cursor is positioned over a histogram bin. If this option is used, it replaces all the information displayed by default. Roles for columns that do not contribute to the histogram can be specified along with roles that do.
Default: The columns assigned to these roles are automatically included in the tooltip information: X and Y.
(role-list)
an ordered, blank-separated list of unique HISTOGRAMPARM and user-defined roles. HISTOGRAMPARM roles include X, Y, and DATALABEL.
User-defined roles are defined with the ROLENAME= option.
The following example displays tooltips for the columns assigned to the roles X and Y, as well as the column PCT, which is not assigned to any pre-defined HISTOGRAMPARM role. The PCT column must first be assigned a role.:
  ROLENAME=(TIP1=PCT)
  TIP= (X Y TIP1)
Requirement: To generate tooltips, you must include an ODS GRAPHICS ON statement that has the IMAGEMAP option specified, and write the graphs to the ODS HTML destination.
Interaction: The labels and formats for the TIP variables can be controlled with the TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns.
Default: The column format of the variable assigned to the role or BEST6. if no format is assigned to a numeric column.
(role-format-list)
a list of rolename = format pairs separated by blanks.
  ROLENAME=(TIP1=PCT)
  TIP=(X Y TIP1)
  TIPFORMAT=(TIP1=PERCENT7.2) 
Requirement: This option provides a way to control the formats of columns that appear in tooltips. Only the roles that appear in the TIP= option are used. Columns must be assigned to the roles for this option to have any effect. See the ROLENAME= option.
TIPLABEL=(role-label-list)
specifies display labels for tip columns.
Default: The column label or column name of the variable assigned to the role.
(role-label-list)
a list of rolename = "string" pairs separated by blanks.
   ROLENAME=(TIP1=PCT) 
   TIP=(X Y TIP1)
   TIPLABEL=(TIP1="Percent")
Requirement: This option provides a way to control the labels of columns that appear in tooltips. Only the roles that appear in the TIP= option are used. Columns must be assigned to the roles for this option to have any effect. See the ROLENAME= option.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the secondary X2 (top) axis.
Default: X
Interaction: The overall plot specification and the layout type determine the axis display. For more information, see How Axis Features Are Determined.
XVALUES=MIDPOINTS | LEFTPOINTS | RIGHTPOINTS
specifies whether the X values represent midpoints, lower endpoints, or upper endpoints of the bins.
Default: MIDPOINTS
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2 (right) axis.
Default: Y
Interaction: The overall plot specification and the layout type determine the axis display. For more information, see How Axis Features Are Determined.