• Print  |
  • Feedback  |

TEMPLATE Procedure: Plot Statements (Experimental)

DENSITYPLOT Statement


Displays a univariate probability density curve computed from input data, and typically is used to create normal density curves and non-parametric kernel density curves.
DENSITYPLOT numeric-column | expression < / <distribution option> <option(s)>> ;


Usage Information

Density Histogram

[Density Histogram]

Tip:

A typical DENSITYPLOT statement specifies either the NORMAL or the KERNEL distribution option. Thus, one common plot syntax would be one of the following statements.

DENSITYPLOT numeric-column / NORMAL()

Another common plot syntax would be:

DENSITYPLOT numeric-column / KERNEL()

Tip:

If no distribution option is specified, then NORMAL is assumed.

Tip:

If more than one distribution option is specified, then the last distribution option specified is used.


Required Arguments

numeric-column

specifies a numeric column of data values that are used to calculated the parameters for the probability distribution.

expression

specifies a selective, relational, or logical program structure that calculates values when those values are not stored in the data.


Distribution Options

KERNEL ( < C= number > <, WEIGHT= NORMAL | TRIANGULAR | QUADRATIC > )

specifies a non-parametric kernel density estimate. The general form of the kernel density estimator is as follows.

[untitled graphic]

In the equation, K0 (.) is the weight function, [lambda] is the bandwidth, n is the sample size, and xi is the ith observation. You can use the C= sub-option to specify the bandwith and the WEIGHT= sub-option to specify the weight function K0 (.).

For more information, see the discussion of Kernel Density Estimates for the UNIVARIATE procedure in the Base SAS Procedures Guide, Volume 3.

C

specifies the number that represents the standardized bandwidth.

Default: Calculated from the data as the bandwidth that minimizes the approximate mean integrated square error (MISE).

The value of [lambda], referred to as the bandwidth parameter, determines the degree of smoothness in the estimated density function. You specify [lambda] indirectly by specifying a standardized bandwidth c with the C= kernel-option. If Q is the interquartile range, and n is the sample size, then c is related to by the following formula.

[untitled graphic]

WEIGHT

specifies a weight function.

Default: NORMAL
Tip: The formulas for the weight functions are as follows.

[untitled graphic]

NORMAL ( < MU= number > < , SIGMA= number > )

specifies a normal density estimate, with mean and standard deviation. The fitted density function equation is as follows.

[untitled graphic]

In the equation, [mu] is the mean, and [sigma] is the standard deviation ([sigma] > 0). You can specify [mu] with the MU= sub-option and [sigma] with the SIGMA= sub-option. By default, ODS estimates [mu] with the sample mean and [sigma] with the sample standard deviation.

For more information, see the discussion of Kernel Density Estimates for the UNIVARIATE procedure in the Base SAS Procedures Guide, Volume 3.

Tip: If mean and standard deviation are not specified, then they are calculated from the data.
MU

specifies the mean.

SIGMA

specifies the standard deviation.


Options

DENSITYPLOT Options
Option Description
BACKGROUND= color | style-reference Specifies the background color of the graph.
BACKTRANSPARENCY= number Specifies the degree of the transparency of the background color.
DATATRANSPARENCY= number Specifies the degree of the transparency of the density curve.
GRIDTRANSPARENCY= number Specifies the degree of the transparency of the grid lines.
LEGENDLABEL= 'string' Specifies the label of the legends.
LINECOLOR= color | style-reference Specifies the color of the density curve line.
LINEPATTERN= line | style-reference Specifies the pattern of the density curve line.
LINETHICKNESS= dimension | style-reference Specifies the thickness of the density curve line.
NAME= 'string' Assigns a name to a plot statement for reference in other template statements.
TRANSPARENCY= number Specifies the degree of the transparency of the density curve, background, grid, axis elements, and wall, if displayed in the graph.
WALLTRANSPARENCY= number Specifies the degree of the transparency of the plot wall.
XAXIS= X | X2 Specifies whether curve is mapped to the primary X axis or the secondary X (X2) axis.
XAXISOPTS= ( axis-options ) Specifies one or more X axis options.
XGRID= boolean Specifies whether the grid lines are drawn at the tick marks.
XMAX= number Specifies the maximum X value to use in the display of the curve.
XMIN= number Specifies the minimum X value to use in the display of the curve.
XOFFSETMAX= number Specifies an offset to add to the end that represents high data values on the primary X axis.
XOFFSETMIN= number Specifies an offset to add to the end that represents low data values on the primary X axis.
YAXIS= Y | Y2 Specifies whether curve is mapped to the primary Y axis or the secondary Y (Y2) axis.
YAXISOPTS= ( axis-options ) Specifies one or more Y axis options.
YGRID= boolean Specifies whether the grid lines drawn at the tick marks.
YMAX= number Specifies the maximum Y value to use in the display of the curve.
YMIN= number Specifies the minimum Y value to use in the display of the curve.
YOFFSETMAX= number Specifies an offset to add to the end that represents high data values on the primary Y axis.
YOFFSETMIN= number Specifies an offset to add to the end that represents low data values on the primary Y axis.

BACKGROUND= color | style-reference

specifies the background color of the graph.

Default: Specified by the GraphBackground:Background style reference.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
BACKTRANSPARENCY= number

specifies the degree of the transparency of the background color.

Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Interaction: The BACKTRANSPARENCY= option overrides the TRANSPARENCY= option for the background.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
See also: TRANSPARENCY= option
DATATRANSPARENCY= number

specifies the degree of the transparency of the density curve.

Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Interaction: The DATATRANSPARENCY= option overrides the TRANSPARENCY= option for the graph elements in the data area.
GRIDTRANSPARENCY= number

specifies the degree of the transparency of the grid lines.

Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Interaction: The GRIDTRANSPARENCY= option overrides the TRANSPARENCY= option for the grid lines.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
See also: TRANSPARENCY= option
LEGENDLABEL= 'string'

specifies the label of the legends.

Default: An empty string.
LINECOLOR= color | style-reference

specifies the color of the density curve line.

Default: Specified by the GraphDataDefault:ContrastColor style reference.
LINEPATTERN= line | style-reference

specifies the pattern of the density curve line.

Default: SOLID
LINETHICKNESS= dimension | style-reference

specifies the thickness of the density curve line.

Default: 1 px
NAME= 'string'

assigns a name to a plot statement for reference in other template statements.

Restriction: The string specified by the NAME= option must be unique within the template.
Restriction: The string specified by the NAME= option cannot contain embedded spaces.
Tip: The NAME= option is used mostly in the DISCRETELEGEND statement in order to coordinate the use of colors, marker symbols, and line patterns between the graph and the legend.
Tip: string is case sensitive.
TRANSPARENCY= number

specifies the degree of the transparency of the density curve, background, grid, axis elements, and wall, if displayed in a graph.

Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Interaction: The transparency for the density curve, background, grid, and wall can be set individually with the BACKTRANSPARENCY=, DATATRANSPARENCY=, GRIDTRANSPARENCY=, and WALLTRANSPARENCY= options. If you specify the TRANSPARENCY= option for a graph, then the individual transparency options can be specified to override it for individual features. The settings remain in effect for other features that are not individually overridden.
Interaction: In an OVERLAY LAYOUT block, the TRANSPARENCY= option only affects the density curve. The LAYOUT OVERLAY statement settings control the transparency of the background, grid, axis elements, and wall.
WALLTRANSPARENCY= number

specifies the degree of the transparency of the plot wall.

Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
Interaction: The WALLTRANSPARENCY= option overrides the TRANSPARENCY= option for the graph wall.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
XAXIS= X | X2

specifies whether data is mapped to the primary X axis or to the secondary X (X2) axis.

Default: X
Interaction: Outside of a LAYOUT OVERLAY block, an individual plot can have only one X axis. The XAXIS= option of a plot specifies whether the axis is in the primary (bottom) or secondary (top) position. The XAXISOPTS= option of a plot specifies whether the axis is displayed and specifies the axis characteristics.

Within a LAYOUT OVERLAY block, multiple plots can share a primary axis and a secondary axis. The primary and secondary axes can have different scales, and the XAXIS= option for a particular plot can map data to either axis. The XAXISOPTS= and X2AXISOPTS= options of a LAYOUT OVERLAY statement specify whether the axes are displayed, and specify the axis characteristics.

XAXISOPTS= ( axis-options )

specifies one or more X axis options.

Requirement: The list of axis options must be enclosed in parentheses and separated by spaces.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
XGRID= boolean

specifies whether the grid lines are drawn at the tick marks.

Default: FALSE
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Interaction: If you specify or use the default XGRID= option for the OVERLAY LAYOUT statement, then the XGRID= option specified for a graph is ignored. Default characteristics for the grid lines are specified from the following attributes on the GraphGridLines style element:
Color

Foreground

Thickness

LineThickness (default=1 px)

Pattern

LineStyle (default=1)

XMAX= number

specifies the maximum X value to use in the display of the curve.

Default: The default value is the maximum X value in the curve.
Tip: If the curve contains values greater than the number specified for the XMAX= option, then the values are excluded from the plot.
XMIN= number

specifies the minimum X value to use in the display of the curve.

Default: The default value is the minimum X value in the curve.
Tip: If the curve contains values that are less than the number specified for the XMIN= option, then the values are excluded from the plot.
XOFFSETMAX= number

specifies an offset to add to the end that represents high data values on the primary X axis. The offset is expressed as a decimal proportion of the full axis length. For a continuous axis, the offset is added to the highest data value or highest tick value, whichever is greater. For a discreet axis, the offset is added to the highest data value, which is always the highest tick value.

Default: Generated as suitable for the graph.
Range: 0 - 1
Interaction: For a continuous axis, the offset is added after any threshold adjustment is made to the axis.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Main discussion: THRESHOLDMAX= sub-option.
XOFFSETMIN= number

specifies an offset to add to the end that represents low data values on the primary X axis. The offset is expressed as a decimal proportion of the full axis length. For a continuous axis, the offset is added to the lowest data value or lowest tick value, whichever is less. For a discreet axis, the offset is added to the lowest data value, which is always the lowest tick value.

Default: Generated as suitable for the graph.
Range: 0 - 1
Interaction: For a continuous axis, the offset is added after any threshold adjustment is made to the axis.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Main discussion: THRESHOLDMAX= sub-option.
YAXIS= Y | Y2

specifies whether data is mapped to the primary Y axis or to the secondary Y (Y2) axis.

Default: Y
Interaction: Outside of a LAYOUT OVERLAY block, an individual plot can have only one Y axis. The YAXIS= option of a plot specifies whether the axis is in the primary (left) or secondary (right) position. The YAXISOPTS= option of a plot specifies whether the axis is displayed and specifies the axis characteristics.

Within a LAYOUT OVERLAY block, multiple plots can share a primary axis and a secondary axis. The primary and secondary axes can have different scales, and the YAXIS= option for a particular plot can map data to either axis. The YAXISOPTS= and Y2AXISOPTS= options of a LAYOUT OVERLAY statement specify whether the axes are displayed, and specify the axis characteristics.

YAXISOPTS= ( axis-options )

specifies one or more Y axis options.

Requirement: The list of axis options must be enclosed in parentheses and separated by spaces.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
YGRID= boolean

specifies whether grid lines are drawn at the tick marks.

Default: FALSE
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Interaction: If you specify or use the default YGRID= option for the OVERLAY LAYOUT statement, then the YGRID= option specified for a graph is ignored. Default characteristics for the grid lines are specified from the following attributes on the GraphGridLines style element:
Color

Foreground

Thickness

LineThickness (default=1 px)

Pattern

LineStyle (default=1)

YMAX= number

specifies the maximum Y value to use in the display of the curve.

Default: The default value is the maximum Y value in the curve.
Tip: If the data contains values that are greater than the number specified for the YMAX= option, then the values are excluded from the plot.
YMIN= number

specifies the minimum Y value to use in the display of the curve.

Default: The default value is the minimum Y value in the curve.
Tip: If the data contains values that are less than the number specified for the YMIN= option, then the values are excluded from the plot.
YOFFSETMAX= number

specifies an offset to add to the end that represents high data values on the primary Y axis. The offset is expressed as a decimal proportion of the full axis length. For a continuous axis, the offset is added to the highest data value or highest tick value, whichever is greater. For a discreet axis, the offset is added to the highest data value, which is always the highest tick value.

Default: Generated as suitable for the graph.
Range: 0 - 1
Interaction: For a continuous axis, the offset is added after any threshold adjustment is made to the axis.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Main discussion: THRESHOLDMAX= sub-option.
YOFFSETMIN= number

specifies an offset to add to the end that represents low data values on the primary Y axis. The offset is expressed as a decimal proportion of the full axis length. For a continuous axis, the offset is added to the lowest data value or lowest tick value, whichever is less. For a discreet axis, the offset is added to the lowest data value, which is always the lowest tick value.

Default: Generated as suitable for the graph.
Range: 0-1
Interaction: For a continuous axis, the offset is added after any threshold adjustment is made to the axis.
Interaction: Ignored in a LAYOUT OVERLAY block. For information, see Ignored Plot Options in a LAYOUT OVERLAY Block.
Main discussion: THRESHOLDMAX= sub-option.


Previous Page | Next Page | Top of Page