|The SGPLOT Procedure|
|Restriction:||The DENSITY statement cannot be used with discrete axes.|
|Interaction:||The DENSITY statement can be combined only with DENSITY and HISTOGRAM statements in the SGPLOT procedure.|
|Featured in:||Combining Histograms with Density Plots|
|DENSITY response-variable </ option(s)>;|
option(s) can be one or more options from the following categories:
LINEATTRS= style-element <(options)> | (options)
TYPE = NORMAL < (normal-opts)>| KERNEL < (kernel-opts)>
specifies the variable for the x axis. The variable must be numeric.
specifies that 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.
specifies a label that identifies the density plot in the legend. By default, the label identifies the type of density curve. If you specify TYPE=NORMAL, then the default label is "Normal." If you specify TYPE=KERNEL, then the default label is "Kernel."
Note: User-specified parameters from the TYPE= option are included in the label by default.
specifies the appearance of the density line. You can specify the appearance by using a style element or by using suboptions. If you specify a style element, you can additionally specify suboptions to override specific appearance attributes.
options can be one or more of the following:
specifies the color of the line. For more information about specifying colors, see SAS/GRAPH Colors and Images in the SAS/GRAPH: Reference, Second Edition.
|Default:||The default color is specified by the ContrastColor attribute of the GraphFit style element in the current style.|
specifies the line pattern for the line. You can reference SAS patterns by number or by name. See Line Patterns for a list of line patterns.
|Default:||The default line pattern is specified by the LineStyle attribute of the GraphFit style element in the current style.|
specifies the thickness of the line. You can also specify the unit of measure. The default unit is pixels. See Units of Measurement for a list of the measurement units that are supported.
|Default:||The default line thickness is specified by the LineThickness attribute of the GraphFit style element in the current style.|
specifies a name for the plot. You can use the name to refer to this plot in other statements.
specifies the scaling that is used for the response axis. Specify one of the following values:
the axis displays the frequency count.
the axis displays the density estimate values.
the axis displays values as a percentage of the total.
the axis displays values in proportion to the total.
Note: The PROPORTION scale can be used only when you combine a density plot and a histogram together.
specifies the degree of transparency for the density curve. Specify a value from 0.0 (completely opaque) to 1.0 (completely transparent).
specifies the type of distribution curve that is used for the density plot. Specify one of the following keywords:
specifies a normal density estimate, with a mean and a standard deviation.
normal-opts can be one or more of the following values:
specifies the mean value that is used in the density function equation. By default, the mean value is calculated from the data.
specifies the standard deviation value that is used in the density function equation. The value that you specify for the SIGMA= suboption must be a positive number. By default, the standard deviation value is calculated from the data.
specifies a nonparametric kernel density estimate.
kernel-opts can be:
specifies the standardized bandwidth for a number that is greater than 0 and less than or equal to 100.
The value that you specify for the C= suboption affects the value of as shown in the following equation:
In this equation c is the standardized bandwidth, Q is the interquartile range, and n is the sample size.
specifies the weight function. You can specify either normal, quadratic, or triangular weight function.
assigns the X variable to the secondary (top) horizontal axis.
assigns the calculated result to the secondary (right) vertical axis.
When the type of the density curve is NORMAL, the fitted density function equation is as follows:
In the equation, is the mean, and is the standard deviation. You can specify by using the MU= suboption and by using the SIGMA= suboption.
When the TYPE of the density curve is KERNEL, the general form of the kernel density estimator is as follows:
In the equation, is the weight function, is the bandwidth, n is the sample size, and is the ith observation. You can use the C= suboption to specify the bandwidth and the WEIGHT= suboption to specify the weight function .
The formulas for the weight functions are as follows: