This documentation is for a version of the software that is not covered by Standard Support. Select a different version from the version selector in the banner, or access the latest documentation.
The OUTPUT statement saves statistics, BY variables, and CLASS variables in an output data set. When you specify a BY statement or a CLASS statement, or both, there is an observation in the output data set that corresponds to each combination of BY groups and CLASS variable values. Otherwise, the output data set contains only one observation.
You can use any number of OUTPUT statements in the UNIVARIATE procedure. Each OUTPUT statement creates a new data set to contain the statistics that are specified in that statement. You must use the VAR statement with the OUTPUT statement. The OUTPUT statement must contain a specification of the form keyword=names or the PCTLPTS= and PCTLPRE= options. See Example 3.7 and Example 3.8.
You can use the OUT= option to specify the name of the output data set:
OUT=SAS-data-set
identifies the output data set. If SAS-data-set does not exist, PROC UNIVARIATE creates it. If you omit this option, the data set is named DATAn, where n is the smallest integer that makes the name unique.
A keyword=names specification selects a statistic to be included in the output data set and specifies the names of new variables that contain the statistic. Specify a keyword for each desired statistic, followed by an equal sign, followed by the names of the variables to contain the statistic. In the output data set, the first variable listed after a keyword in the OUTPUT statement contains the statistic for the first variable listed in the VAR statement, the second variable contains the statistic for the second variable in the VAR statement, and so on. If the list of names following the equal sign is shorter than the list of variables in the VAR statement, the procedure uses the names in the order in which the variables are listed in the VAR statement. The available keywords are listed in Table 14.
Table 14: 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
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
Quantile 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)
Robust Statistic Keywords
GINI
Gini’s mean difference
MAD
Median absolute difference about the median
QN
, alternative to MAD
SN
, alternative to MAD
STD_GINI
Gini’s standard deviation
STD_MAD
MAD standard deviation
STD_QN
standard deviation
STD_QRANGE
Interquartile range standard deviation
STD_SN
standard deviation
Hypothesis Testing Keywords
MSIGN
Sign statistic
NORMALTEST
Test statistic for normality
SIGNRANK
Signed rank statistic
PROBM
Probability of a 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
Statistic for the Student’s t test
The UNIVARIATE procedure automatically computes the 1st, 5th, 10th, 25th, 50th, 75th, 90th, 95th, and 99th percentiles for the data. You can save these in an output data set by using keyword=names specifications. You can request additional percentiles by using the PCTLPTS= option. The following percentile-options are related to these additional percentiles:
requests distribution-free confidence limits for percentiles that are requested by the PCTLPTS= option. In other words, no specific parametric distribution such as the normal is assumed for the data. PROC UNIVARIATE uses order statistics (ranks) to compute the confidence limits as described by Hahn and Meeker (1991). This option does not apply if you use a WEIGHT statement. You can specify the following cipctl-options:
ALPHA=
specifies the level of significance for confidence intervals, where must be between 0 and 1. The default value is the value of ALPHA= that is specified in the PROC statement.
LOWERPRE=prefixes
specifies one or more prefixes that are used to create names for variables that contain the lower confidence limits. To save lower confidence limits for more than one analysis variable, specify a list of prefixes. The order of the prefixes corresponds to the order of the analysis variables in the VAR statement.
LOWERNAME=suffixes
specifies one or more suffixes that are used to create names for variables that contain the lower confidence limits. PROC UNIVARIATE creates a variable name by combining the LOWERPRE= value and the suffix name. Because the suffixes are associated with the requested percentiles, list the suffixes in the same order as the PCTLPTS= percentiles.
TYPE=LOWER |UPPER |SYMMETRIC |ASYMMETRIC
specifies the type of confidence limit. By default, TYPE=SYMMETRIC.
UPPERPRE=prefixes
specifies one or more prefixes that are used to create names for variables that contain the upper confidence limits. To save upper confidence limits for more than one analysis variable, specify a list of prefixes. The order of the prefixes corresponds to the order of the analysis variables in the VAR statement.
UPPERNAME=suffixes
specifies one or more suffixes that are used to create names for variables that contain the upper confidence limits. PROC UNIVARIATE creates a variable name by combining the UPPERPRE= value and the suffix name. Because the suffixes are associated with the requested percentiles, list the suffixes in the same order as the PCTLPTS= percentiles.
Note: See the entries for the PCTLPTS=, PCTLPRE=, and PCTLNAME= options for a detailed description of how variable names are created using prefixes, percentile values, and suffixes.
requests confidence limits based on the assumption that the data are normally distributed for percentiles that are requested in the PCTLPTS= option. The computational method is described in Section 4.4.1 of Hahn and Meeker (1991) and uses the noncentral t distribution as given by Odeh and Owen (1980). This option does not apply if you use a WEIGHT statement. You can specify the following cipctl-options:
ALPHA=
specifies the level of significance for confidence intervals, where must be between 0 and 1. The default value is the value of ALPHA= given in the PROC statement.
LOWERPRE=prefixes
specifies one or more prefixes that are used to create names for variables that contain the lower confidence limits. To save lower confidence limits for more than one analysis variable, specify a list of prefixes. The order of the prefixes corresponds to the order of the analysis variables in the VAR statement.
LOWERNAME=suffixes
specifies one or more suffixes that are used to create names for variables that contain the lower confidence limits. PROC UNIVARIATE creates a variable name by combining the LOWERPRE= value and the suffix name. Because the suffixes are associated with the requested percentiles, list the suffixes in the same order as the PCTLPTS= percentiles.
TYPE=LOWER |UPPER |TWOSIDED
specifies the type of confidence limit. By default, TYPE=TWOSIDED.
UPPERPRE=prefixes
specifies one or more prefixes that are used to create names for variables that contain the upper confidence limits. To save upper confidence limits for more than one analysis variable, specify a list of prefixes. The order of the prefixes corresponds to the order of the analysis variables in the VAR statement.
UPPERNAME=suffixes
specifies one or more suffixes that are used to create names for variables that contain the upper confidence limits. PROC UNIVARIATE creates a variable name by combining the UPPERPRE= value and the suffix name. Because the suffixes are associated with the requested percentiles, list the suffixes in the same order as the PCTLPTS= percentiles.
Note: See the entries for the PCTLPTS=, PCTLPRE=, and PCTLNAME= options for a detailed description of how variable names are created using prefixes, percentile values, and suffixes.
PCTLGROUP=BYSTAT |BYVAR
specifies the order in which variables that you request with the PCTLPTS= option are added to the OUT= data set when the VAR statement lists more than one analysis variable. You can specify the following values:
BYSTAT
creates all variables that are associated with a percentile value consecutively.
BYVAR
creates all variables that are associated with an analysis variable consecutively.
The order of variables in the data set ByStat is Pre_20, Post_20, Pre_40, Post_40. The order of variables in the data set ByVar is Pre_20, Pre_40, Post_20, Post_40.
PCTLNAME=suffixes
specifies one or more suffixes that are used to create the names for the variables that contain the PCTLPTS= percentiles by combining the PCTLPRE= option value and the suffixes. Because the suffixes are associated with the percentiles that are requested, list the suffixes in the same order as the PCTLPTS= percentiles. If you specify nsuffixes in the PCTLNAME= option and m percentile values in the PCTLPTS= option where , the suffixes are used to name the first n percentiles and default names are used for the remaining percentiles. For example, consider the following statements:
The value twenty in the PCTLNAME= option is used for only the first percentile in the PCTLPTS= list. This suffix is appended to the values in the PCTLPRE= option to generate the new variable names pltwenty, pwtwenty, and phtwenty, which contain the 20th percentiles for Length, Width, and Height, respectively. Because a second PCTLNAME= suffix is not specified, variable names for the 40th percentiles for Length, Width, and Height are generated by using the prefixes and percentile values. Thus, the output data set contains the variables pltwenty, pl40, pwtwenty, pw40, phtwenty, and ph40.
You must specify PCTLPRE= to supply prefix names for the variables that contain the PCTLPTS= percentiles.
If the number of PCTLNAME= values is fewer than the number of percentiles or if you omit PCTLNAME=, PROC UNIVARIATE uses the percentile as the suffix to create the name of the variable that contains the percentile. For an integer percentile, PROC UNIVARIATE uses the percentile. Otherwise, PROC UNIVARIATE truncates decimal values of percentiles to two decimal places and replaces the decimal point with an underscore.
If either the combination of prefix and suffix names or the combination of prefix and percentile names is longer than 32 characters, PROC UNIVARIATE truncates the prefix name so that the variable name is 32 characters.
PCTLNDEC=value
specifies the number of decimal places in percentile values that are incorporated into percentile variable names. For example, the following statements create two output data sets, each containing one percentile variable. The variable in data set short is named pwid85_12, whereas the one in data set long is named pwid85_125.
specifies one or more prefixes to create the variable names for the variables that contain the PCTLPTS= percentiles. To save the same percentiles for more than one analysis variable, specify a list of prefixes. The order of the prefixes corresponds to the order of the analysis variables in the VAR statement. The PCTLPRE= and PCTLPTS= options must be used together.
PROC UNIVARIATE generates new variable names by using the prefix and the percentile values. If the specified percentile is an integer, the variable name is simply the prefix followed by the value. If the specified value is not an integer, an underscore replaces the decimal point in the variable name, and decimal values are truncated to one decimal place. For example, the following statements create the variables pwid20, pwid33_3, pwid66_6, and pwid80 for the 20th, 33.33rd, 66.67th, and 80th percentiles of Width, respectively:
If you request percentiles for more than one variable, you should list prefixes in the same order in which the variables appear in the VAR statement. If combining the prefix and percentile value results in a name longer than 32 characters, the prefix is truncated so that the variable name is 32 characters.
PCTLPTS=percentiles
specifies one or more percentiles to be computed in addition to the percentiles that PROC UNIVARIATE automatically computes. The PCTLPRE= and PCTLPTS= options must be used together. You can specify percentiles with an expression of the form start TO stop BY increment where start is a starting number, stop is an ending number, and increment is a number to increment by. The PCTLPTS= option generates additional percentiles and outputs them to a data set. These additional percentiles are not printed.
To compute the 50th, 95th, 97.5th, and 100th percentiles, submit the statement
output pctlpre=P_ pctlpts=50,95to100by2.5;
PROC UNIVARIATE computes the requested percentiles based on the method that you specify in the PCTLDEF= option in the PROC UNIVARIATE statement. You must use PCTLPRE=, and optionally PCTLNAME=, to specify variable names for the percentiles. For example, the following statements create an output data set named Pctls that contains the 20th and 40th percentiles of the analysis variables PreTest and PostTest:
PROC UNIVARIATE saves the 20th and 40th percentiles for PreTest and PostTest in the variables PreTest_P20, PostTest_P20, PreTest_P40, and PostTest_P40.