SGPLOT Procedure

HISTOGRAM Statement

Creates a histogram that displays the frequency distribution of a numeric variable.
Interaction: The HISTOGRAM statement can be combined only with DENSITY statements in the SGPLOT procedure.
Note: The range of the response variable is automatically divided into an appropriate number of bins.
About Histograms

Combining Histograms with Density Plots

Syntax

HISTOGRAM response-variable </ option(s)>;

Summary of Optional Arguments

Histogram options
specifies the X coordinate of the first bin.
specifies the bin width.
specifies how boundary values are assigned to bins.
specifies whether the area fill is visible.
specifies the appearance of the area fill.
specifies the number of bins.
specifies whether outlines are displayed for the bars.
specifies the scaling that is applied to the vertical axis.
specifies that the midpoints of the value bins are used to create the tick marks for the horizontal axis.
Plot options
specifies how many times observations are repeated for computational purposes.
specifies a label that identifies the histogram in the legend.
specifies a name for the plot.
specifies the degree of transparency for the histogram.
assigns the response variable to the secondary (top) horizontal axis.
assigns the calculated values to the secondary (right) vertical axis.

Required Argument

response-variable
specifies the response variable for the histogram.

Optional Arguments

BINSTART= numeric-value
specifies the X coordinate of the first bin. Use this option in conjunction with the BINWIDTH= or NBINS= options to specify bins. If neither BINWIDTH= nor the NBINS= option is specified, the system determines the number of bins. If the BINSTART value results in excluding the entire range of data, it is ignored and the default BINSTART value is used.
Default:The default value is determined by the system.
BINWIDTH= numeric-value
specifies the bin width. The system determines the number of bins. The bins always span the range of the data.
Default:The default value is determined by the system.
Interactions:

This option is ignored if the NBINS= option is also specified.

BOUNDARY= LOWER | UPPER
specifies how boundary values are assigned to bins.
LOWER
specifies that boundary values are assigned to the lower bin.
UPPER
specifies that boundary values are assigned to the upper bin.
Default:UPPER
FILL | NOFILL
specifies whether the area fill is visible. The FILL option shows the area fill. The NOFILL option hides the area fill.
Default:The default status of the area fill is specified by the DisplayOpts attribute of the GraphHistogram style element in the current style.
Interactions:Specifying FILL also hides any visible outlines.

If NOFILL and NOOUTLINE are both specified, then both options are ignored.

FILLATTRS= style-element | (COLOR= color)
specifies the appearance of the area fill. You can specify the color of the fill by using a style element or by using the COLOR= suboption. You can specify colors using the same color schemes that are supported by SAS/GRAPH software. For more information, see Color-Naming Schemes in SAS/GRAPH: Reference.
Default:The default color is specified by the Color attribute of the GraphDataDefault style element in the current style.
Interaction:This option has no effect if you specify the NOFILL option.
FREQ= numeric-variable
specifies how many times observations are repeated for computational purposes. Each observation is repeated n times for computational purposes, where n is the value of the numeric variable. If n is not an integer, then it is truncated to an integer. If n is less than 1 or missing, then it is excluded from the analysis.
LEGENDLABEL= “text-string
specifies a label that identifies the histogram in the legend. By default, the label of the response variable is used.
NAME= “text-string
specifies a name for the plot. You can use the name to refer to this plot in other statements.
Note:The name is case-sensitive. When you refer to the specified name in other statements, you must use the same exact capitalization.
NBINS= numeric-value
specifies the number of bins. The system determines the BINWIDTH= value. The bins always span the range of the data.
The procedure attempts to produce tick values that are easily interpreted (for example, 5, 10, 15, 20). The procedure sometimes adjusts the location of the first bin and the bin width accordingly. As a result, the number of bins shown in the plot might not exactly match the number specified with NBINS=.
Default:The default number of bins is determined by the system.
OUTLINE | NOOUTLINE
specifies whether outlines are displayed for the bars. The OUTLINE option shows the outlines. The NOOUTLINE option hides the outlines.
Default:The default status of the outlines is specified by the DisplayOpts attribute of the GraphHistogram style element in the current style.
Interactions:Specifying OUTLINE also hides the fill color.

If NOOUTLINE and NOFILL are both specified, then both options are ignored.

SCALE= COUNT | PERCENT | PROPORTION
specifies the scaling that is applied to the vertical axis. Specify one of the following values:
COUNT
the axis displays the frequency count.
PERCENT
the axis displays values as a percentage of the total.
PROPORTION
the axis displays values as proportions (0.0 to 1.0) of the total.
Default:PERCENT
SHOWBINS
specifies that the midpoints of the value bins are used to create the tick marks for the horizontal axis. By default, the tick marks are created at regular intervals based on the minimum and maximum values.
TRANSPARENCY= numeric-value
specifies the degree of transparency for the histogram. Specify a value from 0.0 (completely opaque) to 1.0 (completely transparent).
Default:0.0
X2AXIS
assigns the response variable to the secondary (top) horizontal axis.
Y2AXIS
assigns the calculated values to the secondary (right) vertical axis.