| TEMPLATE Procedure: Plot Statements (Experimental) |
| DENSITY numeric-column | expression < / <distribution-option> <option(s)>> ; |
| Usage Information |
Density Histogram
![[Density Histogram]](./images/density.gif)
| Tip: |
A typical DENSITY statement specifies either the NORMAL or the KERNEL distribution option. Thus, one common plot syntax would be one of the following statements.
DENSITY numeric-column / NORMAL()
Another common plot syntax would be:
DENSITY 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 |
specifies a numeric column of data values that are used to calculated the parameters for the probability distribution.
specifies a selective, relational, or logical program structure that calculates values when those values are not stored in the data.
| Distribution Options |
specifies a non-parametric kernel density estimate. The general form of the kernel density estimator is as follows.
![[untitled graphic]](./images/kernel.gif)
In
the equation, K0 (.)
is the weight function,
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.
| ||||
| WEIGHT |
specifies a weight function.
|
specifies a normal density estimate, with mean and standard deviation. The fitted density function equation is as follows.
![[untitled graphic]](./images/normal.gif)
In the equation,
is the mean, and
is the standard deviation (
> 0). You can specify
with the MU= sub-option and
with the SIGMA=
sub-option. By default, ODS estimates
with the sample mean and
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 |
| 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. |
| LEGENDLABEL= 'string' | Specifies the label of the legend. |
| 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, and axis elements, if displayed in a graph. |
| XAXIS= X| X2 | Specifies whether the curve is mapped to the primary X axis or to the secondary X (X2) axis. |
| XMAX= number | Specifies the maximum X data value to use in the display of the curve . |
| XMIN= number | Specifies the minimum X data value to use in the display of the curve. |
| YAXIS= Y | Y2 | Specifies whether the curve is mapped to the primary Y axis or to the secondary Y (Y2) axis. |
| YMAX =number | Specifies the maximum Y data value to use in the display of the curve. |
| YMIN= number | Specifies the minimum Y data value to use in the display of the curve. |
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. |
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 |
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 density curve. |
| See also: | TRANSPARENCY= option |
specifies the label of the legend.
| Default: | No label |
specifies the color of the density curve line.
| Default: | Specified by the GraphDataDefault:ContrastColor style reference. |
specifies the pattern of the density curve line.
| Default: | SOLID |
specifies the thickness of the density curve line.
| Default: | 1 px |
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. |
specifies the degree of the transparency of the density curve, background, and axis elements, if displayed in a graph.
| Default: | 0 |
| Range: | 0 (opaque) to 1 (entirely transparent) |
| Interaction: | The transparency for the density curve and background can be set individually with the BACKTRANSPARENCY= and DATATRANSPARENCY= 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 and axis elements. |
specifies whether the curve is mapped to the primary X axis or to the secondary X (X2) axis.
| Default: | X |
| Interaction: | Within a LAYOUT OVERLAY block, multiple plots can share both a primary 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 determine whether the axes are displayed and set their axis characteristics. |
specifies the maximum X data value to use in the display of the curve.
| Default: | The default value is the maximum X value in the curve. |
| Restriction: | If the curve contains values greater than the number specified for the XMAX= option, then the values are excluded from the plot. |
specifies the minimum X data value to use in the display of the curve.
| Default: | The default value is the minimum X value in the curve. |
| Restriction: | If the curve contains values that are less than the number specified for the XMIN= option, then the values are excluded from the plot. |
specifies whether the curve is mapped to the primary Y axis or to the secondary Y (Y2) axis.
| Default: | Y |
| Interaction: | Within a LAYOUT OVERLAY block, multiple plots can share both a primary 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 determine whether the axes are displayed and set their axis characteristics. |
specifies the maximum Y data value to use in the display of the curve.
| Default: | The default value is the maximum Y value in the curve. |
| Restriction: | If the data contains values that are greater than the number specified for the YMAX= option, then the values are excluded from the plot. |
specifies the minimum Y data value to use in the display of the curve.
| Default: | The default value is the minimum Y value in the curve. |
| Restriction: | If the data contains values that are less than the number specified for the YMIN= option, then the values are excluded from the plot. |