The UNIVARIATE Procedure

INSET Statement

  • INSET keywords </ options>;

An INSET statement places a box or table of summary statistics, called an inset, directly in a graph that is created by a CDFPLOT, HISTOGRAM, PPPLOT, PROBPLOT, or QQPLOT statement. The INSET statement must follow the plot statement that creates the plot that you want to augment. The inset appears in all the graphs that the preceding plot statement produces.

You can use multiple INSET statements after a plot statement to add more than one inset to a plot. See Example 4.17.

In an INSET statement, you specify one or more keywords that identify the information to display in the inset. The information is displayed in the order in which you specify the keywords. Keywords can be any of the following:

Statistical Keywords

The available statistical keywords are listed in Table 10.

Table 10: Statistical Keywords

Keyword Description
Descriptive Statistic Keywords
CSS Corrected sum of squares
CV Coefficient of variation
GEOMEAN Geometric mean
HARMEAN Harmonic mean
KURTOSIS | KURT Kurtosis
MAX Largest value
MEAN Sample mean
MIN Smallest value
MODE Most frequent value
N Sample size
NEXCL Number of observations excluded by the MAXNBIN= or MAXSIGMAS= option
NMISS Number of missing values
NOBS Number of observations
RANGE Range
SKEWNESS | SKEW Skewness
STD | STDDEV Standard deviation
STDMEAN | STDERR Standard error of the mean
SUM Sum of the observations
SUMWGT Sum of the weights
USS Uncorrected sum of squares
VAR Variance
Percentile Statistic Keywords
P1 1st percentile
P5 5th percentile
P10 10th percentile
Q1
P25 Lower quartile (25th percentile)
MEDIAN
Q2
P50 Median (50th percentile)
Q3
P75 Upper quartile (75th percentile)
P90 90th percentile
P95 95th percentile
P99 99th percentile
QRANGE Interquartile range (Q3–Q1)
Keywords for Distribution-Free Confidence Limits for Percentiles (CIPCTLDF Option)
P1_LCL_DF 1st percentile lower confidence limit
P1_UCL_DF 1st percentile upper confidence limit
P5_LCL_DF 5th percentile lower confidence limit
P5_UCL_DF 5th percentile upper confidence limit
P10_LCL_DF 10th percentile lower confidence limit
P10_UCL_DF 10th percentile upper confidence limit
Q1_LCL_DF
P25_LCL_DF Lower quartile (25th percentile) lower confidence limit
Q1_UCL_DF
P25_UCL_DF Lower quartile (25th percentile) upper confidence limit
MEDIAN_LCL_DF
Q2_LCL_DF
P50_LCL_DF Median (50th percentile) lower confidence limit
MEDIAN_UCL_DF
Q2_UCL_DF
P50_UCL_DF Median (50th percentile) upper confidence limit
Q3_LCL_DF
P75_LCL_DF Upper quartile (75th percentile) lower confidence limit
Q3_UCL_DF
P75_UCL_DF Upper quartile (75th percentile) upper confidence limit
P90_LCL_DF 90th percentile lower confidence limit
P90_UCL_DF 90th percentile upper confidence limit
P95_LCL_DF 95th percentile lower confidence limit
P95_UCL_DF 95th percentile upper confidence limit
P99_LCL_DF 99th percentile lower confidence limit
P99_UCL_DF 99th percentile upper confidence limit
Keywords Percentile Confidence Limits Assuming Normality (CIPCTLNORMAL Option)
P1_LCL 1st percentile lower confidence limit
P1_UCL 1st percentile upper confidence limit
P5_LCL 5th percentile lower confidence limit
P5_UCL 5th percentile upper confidence limit
P10_LCL 10th percentile lower confidence limit
P10_UCL 10th percentile upper confidence limit
Q1_LCL
P25_LCL Lower quartile (25th percentile) lower confidence limit
Q1_UCL
P25_UCL Lower quartile (25th percentile) upper confidence limit
MEDIAN_LCL
Q2_LCL
P50_LCL Median (50th percentile) lower confidence limit
MEDIAN_UCL
Q2_UCL
P50_UCL Median (50th percentile) upper confidence limit
Q3_LCL
P75_LCL Upper quartile (75th percentile) lower confidence limit
Q3_UCL
P75_UCL Upper quartile (75th percentile) upper confidence limit
P90_LCL 90th percentile lower confidence limit
P90_UCL 90th percentile upper confidence limit
P95_LCL 95th percentile lower confidence limit
P95_UCL 95th percentile upper confidence limit
P99_LCL 99th percentile lower confidence limit
P99_UCL 99th percentile upper confidence limit
Robust Statistics Keywords
GINI Gini’s mean difference
MAD Median absolute difference about the median
QN upper Q Subscript n, alternative to MAD
SN upper S Subscript n, alternative to MAD
STD_GINI Gini’s standard deviation
STD_MAD MAD standard deviation
STD_QN upper Q Subscript n standard deviation
STD_QRANGE Interquartile range standard deviation
STD_SN upper S Subscript n standard deviation
Hypothesis Testing Keywords
MSIGN Sign statistic
NORMALTEST Test statistic for normality
PNORMAL Probability value for the test of normality
SIGNRANK Signed rank statistic
PROBM Probability of greater absolute value for the sign statistic
PROBN Probability value for the test of normality
PROBS Probability value for the signed rank test
PROBT Probability value for the Student’s t test
T Statistics for Student’s t test
Keyword for Reading an Input Data Set
DATA= (label, value) pairs from input data set


To create a completely customized inset, use a DATA= data set.

DATA=SAS-data-set

requests that PROC UNIVARIATE display customized statistics from a SAS data set in the inset table. The data set must contain two variables:

_LABEL_

is a character variable whose values provide labels for inset entries.

_VALUE_

is a variable that is either character or numeric and whose values provide values for inset entries.

The label and value from each observation in the data set occupy one line in the inset. The position of the DATA= keyword in the keyword list determines the position of its lines in the inset.

Primary and Secondary Keywords

A primary keyword specifies a fitted distribution, which is one of the parametric distributions or a kernel density estimate. You specify secondary keywords in parentheses after the primary keyword to request particular statistics that are associated with that distribution.

Note: When you produce traditional graphics output, you can specify a primary keyword without secondary keywords to display a colored line and the distribution name as a key for the density curve.

In the HISTOGRAM statement, you can request more than one fitted distribution from the same family (for example, two normal distributions). You can display inset statistics for individual curves by specifying the curve indices in square brackets immediately following the primary keyword.

The following statements produce a histogram that has three fitted normal curves and an inset that contains goodness-of-fit statistics for the second curve only:

proc univariate data=score;
   histogram final / normal(sigma=1 2 3);
   inset normal[2](ad adpval);
run;

Table 11 lists the primary keywords and the plot statements with which they can be specified.

Table 11: Primary Keywords

Keyword Distribution Plot Statement Availability
BETA Beta All plot statements
EXPONENTIAL Exponential All plot statements
GAMMA Gamma All plot statements
GUMBEL Gumbel All plot statements
IGAUSS Inverse Gaussian CDFPLOT, HISTOGRAM, PPPLOT
KERNEL Kernel density estimate HISTOGRAM
LOGNORMAL Lognormal All plot statements
NORMAL Normal All plot statements
PARETO Pareto All plot statements
POWER Power function All plot statements
RAYLEIGH Rayleigh All plot statements
SB Johnson upper S Subscript upper B HISTOGRAM
SU Johnson upper S Subscript upper U HISTOGRAM
WEIBULL Weibull (3-parameter) All plot statements
WEIBULL2 Weibull (2-parameter) PROBPLOT, QQPLOT


Table 12 lists the secondary keywords available with the primary keywords listed in Table 11.

Table 12: Secondary Keywords

Secondary Keyword Alias Description
BETA Secondary Keywords
ALPHA SHAPE1 First shape parameter alpha
BETA SHAPE2 Second shape parameter beta
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Lower threshold parameter theta
EXPONENTIAL Secondary Keywords
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
GAMMA Secondary Keywords
ALPHA SHAPE Shape parameter alpha
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
GUMBEL Secondary Keywords
MEAN Mean of the fitted distribution
MU Location parameter mu
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
IGAUSS Secondary Keywords
LAMBDA Shape parameter lamda
MEAN Mean of the fitted distribution
MU Mean parameter mu
STD Standard deviation of the fitted distribution
KERNEL Secondary Keywords
AMISE Approximate mean integrated square error (MISE) for the kernel density
BANDWIDTH Bandwidth lamda for the density estimate
BWIDTH Alias for BANDWIDTH
C Standardized bandwidth for the density estimate
TYPE Kernel type: normal, quadratic, or triangular
LOGNORMAL Secondary Keywords
MEAN Mean of the fitted distribution
SIGMA SHAPE Shape parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
ZETA SCALE Scale parameter zeta
NORMAL Secondary Keywords
MU MEAN Mean parameter mu
SIGMA STD Scale parameter sigma
PARETO Secondary Keywords
ALPHA Shape parameter alpha
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
POWER Secondary Keywords
ALPHA Shape parameter alpha
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
RAYLEIGH Secondary Keywords
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
SB and SU Secondary Keywords
DELTA SHAPE1 First shape parameter delta
GAMMA SHAPE2 Second shape parameter gamma
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Lower threshold parameter theta
WEIBULL Secondary Keywords
C SHAPE Shape parameter c
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Threshold parameter theta
WEIBULL2 Secondary Keywords
C SHAPE Shape parameter c
MEAN Mean of the fitted distribution
SIGMA SCALE Scale parameter sigma
STD Standard deviation of the fitted distribution
THETA THRESHOLD Known lower threshold theta 0
Keywords Available for All Parametric (Non-KERNEL) Distributions
AD Anderson-Darling EDF test statistic
ADPVAL Anderson-Darling EDF test p-value
CVM Cramér–von Mises EDF test statistic
CVMPVAL Cramér–von Mises EDF test p-value
KSD Kolmogorov-Smirnov EDF test statistic
KSDPVAL Kolmogorov-Smirnov EDF test p-value


The inset statistics listed in Table 12 are not available unless you request a plot statement and options that calculate these statistics. For example, consider the following statements:

proc univariate data=score;
   histogram final / normal;
   inset mean std normal(ad adpval);
run;

The MEAN and STD keywords display the sample mean and standard deviation, respectively, of final. The NORMAL keyword with the secondary keywords AD and ADPVAL displays the Anderson-Darling goodness-of-fit test statistic and p-value, respectively. The statistics that are specified with the NORMAL keyword are available only because the NORMAL option is requested in the HISTOGRAM statement.

The KERNEL keyword is available only if you request a kernel density estimate in a HISTOGRAM statement. The WEIBULL2 keyword is available only if you request a two-parameter Weibull distribution in the PROBPLOT or QQPLOT statement.

INSET Statistic Labels and Formats

By default, PROC UNIVARIATE identifies inset statistics with appropriate labels and prints numeric values with appropriate formats. To customize the label, specify the keyword followed by an equal sign (=) and the desired label in quotes. To customize the format, specify a numeric format in parentheses after the keyword. Labels can have up to 24 characters. If you specify both a label and a format for a statistic, the label must appear before the format. For example, the following statement requests customized labels for two statistics and displays the standard deviation with a field width of 5 and two decimal places:

inset n='Sample Size' std='Std Dev' (5.2);

Summary of Options

Table 13 lists INSET statement options, which you can specify after the slash (/) in the INSET statement. For complete descriptions, see the section Dictionary of Options.

Table 13: INSET Options

Option Description
CFILL=color | BLANK Specifies color of inset background
CFILLH=color Specifies color of header background
CFRAME=color Specifies color of frame
CHEADER=color Specifies color of header text
CSHADOW=color Specifies color of drop shadow
CTEXT=color Specifies color of inset text
DATA Specifies data units for POSITION=left parenthesis x comma y right parenthesis coordinates
FONT=font Specifies font of text
FORMAT=format Specifies format of values in inset
GUTTER=value Specifies gutter width for inset in top or bottom margin
HEADER='string' Specifies header text
HEIGHT=value Specifies height of inset text
NCOLS= Specifies number of columns for inset in top or bottom margin
NOFRAME Suppresses frame around inset
POSITION=position Specifies position of inset
REFPOINT=BL | BR | TL | TR Specifies reference point of inset positioned with POSITION=left parenthesis x comma y right parenthesis coordinates


Dictionary of Options

The following entries provide detailed descriptions of the options you can specify in the INSET statement. Options marked with † apply only when traditional graphics are produced.

† CFILL=color |BLANK

specifies the color of the inset background for traditional graphics. You can specify the following values:

color

uses the color for the inset background.

BLANK

leaves the background uncolored, but prevents items from showing through the inset.

By default, the background is empty, which allows items that overlap the inset (such as curves or histogram bars) to show through the inset.

If you do not also specify the CFILLH= option, the value you specify in the CFILL= option applies to the inset header background.

† CFILLH=color

specifies the color of the header background for traditional graphics. The default value is the CFILL= color.

† CFRAME=color

specifies the color of the frame for traditional graphics. The default value is the same color as the axis of the plot.

† CHEADER=color

specifies the color of the header text for traditional graphics. The default value is the CTEXT= color.

† CSHADOW=color

specifies the color of the drop shadow for traditional graphics. By default, a drop shadow is not displayed.

† CTEXT=color

specifies the color of the text for traditional graphics. The default value is the same color as the other text on the plot.

DATA

uses data coordinates to position the inset when the POSITION= option is also specified. The DATA option is available only when you specify POSITION=(x,y). You must place DATA immediately after the coordinates (x,y). Note: Positioning insets with coordinates is not supported for ODS Graphics output.

† FONT=font

specifies the font of the text for traditional graphics. By default, if you locate the inset in the interior of the plot, then the font is SIMPLEX, and if you locate the inset in the exterior of the plot, then the font is the same as the other text on the plot.

FORMAT=format

specifies a format for all the values in the inset. If you specify a format for a particular statistic, then that format overrides the one specified in this option. For more information about SAS formats, see SAS Formats and Informats: Reference.

GUTTER=value

specifies the gutter width in percent screen units for an inset located in the top or bottom margin. The gutter is the space between columns of (label, value) pairs in an inset. By default, GUTTER=4. Note: The GUTTER= option applies only when ODS Graphics is enabled.

HEADER=string

specifies the header text, where string cannot exceed 40 characters. If all the keywords that you list in the INSET statement are secondary keywords that correspond to a fitted curve on a histogram, PROC UNIVARIATE displays a default header that indicates the distribution and identifies the curve. By default, no header line appears in the inset.

† HEIGHT=value

specifies the height of the text for traditional graphics.

NCOLS=n

specifies the number of columns of (label, value) pairs that are displayed in an inset located in the top or bottom margin. By default, NCOLS=3. Note: The NCOLS= option applies only when ODS Graphics is enabled.

NOFRAME

suppresses the frame drawn around the text.

POSITION=position
POS=position

determines the position of the inset. The position is a compass point keyword, a margin keyword, or a pair of coordinates (x,y). You can specify coordinates in axis percentage units or axis data units. See the section Positioning Insets. By default, POSITION=NW, which positions the inset in the upper left (northwest) corner of the display.

Note: Positioning insets with coordinates is not supported for ODS Graphics output.

† REFPOINT=BL |BR |TL |TR

specifies the reference point for an inset that PROC UNIVARIATE positions by using coordinates that are specified in the POSITION= option. The REFPOINT= option specifies the corner of the inset frame you want to position at coordinates (x,y). You can specify the following values:

BL

specifies the bottom left corner.

BR

specifies the bottom right corner.

TL

specifies the top left corner.

TR

specifies the top right corner.

By default, REFPOINT=BL. The REFPOINT= option has no effect unless you specify POSITION=(x,y) coordinates. This option does not apply to ODS Graphics output.

Last updated: April 16, 2025