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 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 use in 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 roles for information defined by data columns.
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. The axis ticks are in predetermined locations and cannot be changed with axis suboptions such TICKVALUELIST= and TICKVALUESEQUENCE=.
Interaction: When this option is set to TRUE, some X-axis options that are set on the parent layout might not apply.
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).
DATATRANSPARENCY= number
specifies the degree of the transparency of the bars (outline and fill).
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
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.
Default: FALSE
Interaction: If this option is set to FALSE, then the axis ticks and value labels are drawn at the bin midpoints. This occurs whether the BINVALUES= option identifies the X data as endpoint values or midpoint values.
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.
LEGENDLABEL= "string"
specifies a label for use in a legend.
Default: The string specified on the NAME= option.
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 GraphDataDefault 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 for information contained in data columns.
Default: no default
(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 and Y.
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 and Y.
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.