Chapter Contents

Previous

Next
SAS Procedures Guide

Keywords and Formulas

The base SAS procedures use a standardized set of keywords to refer to statistics. You specify these keywords in SAS statements to request the statistics to be displayed or stored in an output data set.

In the following notation, summation is over observations that contain nonmissing values of the analyzed variable and, except where shown, over nonmissing weights and frequencies of one or more:

[IMAGE]
is the nonmissing value of the analyzed variable for observation i.

[IMAGE]
is the frequency that is associated with [IMAGE] if you use a FREQ statement. If you omit the FREQ statement, then [IMAGE] for all i.

[IMAGE]
is the weight that is associated with [IMAGE] if you use a WEIGHT statement. The base procedures automatically exclude the values of [IMAGE] with missing weights from the analysis.

By default, the base procedures treat a negative weight as if it is equal to zero. However, if you use the EXCLNPWGT option in the PROC statement, the procedure also excludes those values of [IMAGE] with nonpositive weights. Note that most SAS/STAT procedures, such as PROC TTEST and PROC GLM, exclude values with nonpositive weights by default.

If you omit the WEIGHT statement, then [IMAGE] for all i.

[IMAGE]
is the number of nonmissing value of [IMAGE], [IMAGE]. If you use the EXCLNPWGT option and the WEIGHT statement, then [IMAGE] is the number of nonmissing values with positive weights.

[IMAGE]
is the mean

[IMAGE]

[IMAGE]
is the variance

[IMAGE]

where [IMAGE] is the variance divisor (the VARDEF= option) that you specify in the PROC statement. Valid values are as follows:

When VARDEF= [IMAGE] equals . . .
N [IMAGE]
DF [IMAGE]
WEIGHT [IMAGE]
WDF [IMAGE]

The default is DF.

[IMAGE]
is the standardized variable

[IMAGE]

The standard keywords and formulas for each statistic follow. Some formulas use keywords to designate the corresponding statistic.

The Most Common Simple Statistics
Statistic PROC MEANS and SUMMARY PROC UNIVARIATE PROC TABULATE PROC REPORT PROC CORR PROC SQL
Number of missing values X X X X
X
Number of nonmissing values X X X X X X
Number of observations X X


X
Sum of weights X X X X X X
Mean X X X X X X
Sum X X X X X X
Extreme values X X



Minimum X X X X X X
Maximum X X X X X X
Range X X X X
X
Uncorrected sum of squares X X X X X X
Corrected sum of squares X X X X X X
Variance X X X X X X
Covariance



X
Standard deviation X X X X X X
Standard error of the mean X X X X
X
Coefficient of variation X X X X
X
Skewness X X X


Kurtosis X X X


Confidence Limits






of the mean X X




of the variance
X




of quantiles
X



Median X X X
X
Mode
X



Percentiles/Deciles/Quartiles X X X


t test






for mean=0 X X X X
X

for mean= [IMAGE]
X



Nonparametric tests for location
X



Tests for normality
X



Correlation coefficients



X
Cronbach's alpha



X


Descriptive Statistics
The keywords for descriptive statistics are

CSS
is the sum of squares corrected for the mean, computed as

[IMAGE]

CV
is the percent coefficient of variation, computed as

[IMAGE]

KURTOSIS | KURT
is the kurtosis, which measures heaviness of tails. When VARDEF=DF, the kurtosis is computed as

[IMAGE]

where [IMAGE] is [IMAGE]. The weighted kurtosis is computed as

[IMAGE]

When VARDEF=N, the kurtosis is computed as

[IMAGE]

and the weighted kurtosis is computed as

[IMAGE]

where [IMAGE] is [IMAGE]. The formula is invariant under the transformation [IMAGE]. When you use VARDEF=WDF or VARDEF=WEIGHT, the kurtosis is set to missing.

Note:   PROC MEANS and PROC TABULATE do not compute weighted kurtosis.  [cautionend]

MAX
is the maximum value of [IMAGE].

MEAN
is the arithmetic mean [IMAGE].

MIN
is the minimum value of [IMAGE].

MODE
is the most frequent value of [IMAGE].

N
is the number of [IMAGE] values that are not missing. Observations with [IMAGE] less than one and [IMAGE] equal to missing or [IMAGE] (when you use the EXCLNPWGT option) are excluded from the analysis and are not included in the calculation of N.

NMISS
is the number of [IMAGE] values that are missing. Observations with [IMAGE] less than one and [IMAGE] equal to missing or [IMAGE] (when you use the EXCLNPWGT option) are excluded from the analysis and are not included in the calculation of NMISS.

NOBS
is the total number of observations and is calculated as the sum of N and NMISS. However, if you use the WEIGHT statement, then NOBS is calculated as the sum of N, NMISS, and the number of observations excluded because of missing or nonpositive weights.

RANGE
is the range and is calculated as the difference between maximum value and minimum value.

SKEWNESS | SKEW
is skewness, which measures the tendency of the deviations to be larger in one direction than in the other. When VARDEF=DF, the skewness is computed as

[IMAGE]

where [IMAGE] is [IMAGE]. The weighted skewness is computed as

[IMAGE]

When VARDEF=N, the skewness is computed as

[IMAGE]

and the weighted skewness is computed as

[IMAGE]

The formula is invariant under the transformation [IMAGE]. When you use VARDEF=WDF or VARDEF=WEIGHT, the skewness is set to missing.

Note:   PROC MEANS and PROC TABULATE do not compute weighted skewness.  [cautionend]

STDDEV|STD
is the standard deviation s and is computed as the square root of the variance, [IMAGE].

STDERR | STDMEAN
is the standard error of the mean, computed as

[IMAGE]

when VARDEF=DF, which is the default. Otherwise, STDERR is set to missing.

SUM
is the sum, computed as

[IMAGE]

SUMWGT
is the sum of the weights, [IMAGE], computed as

[IMAGE]

USS
is the uncorrected sum of squares, computed as

[IMAGE]

VAR
is the variance [IMAGE].


Percentile and Related Statistics
The keywords for percentiles and related statistics are

MEDIAN
is the middle value.

P1
is the 1st percentile.

P5
is the 5th percentile.

P10
is the 10th percentile.

P90
is the 90th percentile.

P95
is the 95th percentile.

P99
is the 99th percentile.

Q1
is the lower quartile (25th percentile).

Q3
is the upper quartile (75th percentile).

QRANGE
is interquartile range and is calculated as

[IMAGE]

You use the PCTLDEF= option to specify the method that the procedure uses to compute percentiles. Let [IMAGE] be the number of nonmissing values for a variable, and let [IMAGE] represent the ordered values of the variable such that [IMAGE] is the smallest value, [IMAGE] is next smallest value, and [IMAGE] is the largest value. For the tth percentile between 0 and 1, let [IMAGE]. Then define [IMAGE] as the integer part of [IMAGE] and [IMAGE] as the fractional part of [IMAGE] or [IMAGE], so that

[IMAGE]

Here, PCTLDEF= specifies the method that the procedure uses to compute the tth percentile, as shown in the table that follows.

When you use the WEIGHT statement, the tth percentile is computed as

[IMAGE]

where [IMAGE] is the weight associated with [IMAGE] and [IMAGE] is the sum of the weights. When the observations have identical weights, the weighted percentiles where the same as the unweighted percentiles with PCTLDEF=5.

Methods for Computing Percentile Statistics
PCTLDEF= Description Formula
1 weighted average at [IMAGE] [IMAGE]



where [IMAGE] is taken to be [IMAGE]
2 observation numbered closest to [IMAGE] [IMAGE]
if [IMAGE]


[IMAGE]
if [IMAGE] and [IMAGE] is even


[IMAGE]
if [IMAGE] and [IMAGE] is odd


where i is the integer part of [IMAGE]
3 empirical distribution function [IMAGE]
if [IMAGE]


[IMAGE]
if [IMAGE]
4 weighted average aimed at [IMAGE] [IMAGE]



where [IMAGE] is taken to be [IMAGE]
5 empirical distribution function with averaging [IMAGE]
if [IMAGE]


[IMAGE]
if [IMAGE]


Hypothesis Testing Statistics
The keywords for hypothesis testing statistics are

T
is the Student's t statistic to test the null hypothesis that the population mean is equal to [IMAGE] and is calculated as

[IMAGE]

By default, [IMAGE] is equal to zero. You can use the MU0= option in the PROC UNIVARIATE statement to specify [IMAGE]. You must use VARDEF=DF, which is the default variance divisor, otherwise T is set to missing.

By default, when you use a WEIGHT statement, the procedure counts the [IMAGE] values with nonpositive weights in the degrees of freedom. Use the EXCLNPWGT option in the PROC statement to exclude values with nonpositive weights. Most SAS/STAT procedures, such as PROC TTEST and PROC GLM automatically exclude values with nonpositive weights.

PROBT
is the two-tailed p-value for Student's t statistic, T, with [IMAGE] degrees of freedom. This is the probability under the null hypothesis of obtaining a more extreme value of T than is observed in this sample.


Confidence Limits for the Mean
fThe keywords for confidence limits are

CLM
is the two-sided confidence limit for the mean. A two-sided [IMAGE]percent confidence interval for the mean has upper and lower limits

[IMAGE]

where [IMAGE] is [IMAGE], [IMAGE] is the ( [IMAGE]) critical value of the Student's t statistics with [IMAGE] degrees of freedom, and [IMAGE] is the value of the ALPHA= option which by default is 0.05. Unless you use VARDEF=DF, which is the default variance divisor, CLM is set to missing.

LCLM
is the one-sided confidence limit below the mean. The one-sided [IMAGE]percent confidence interval for the mean has the lower limit

[IMAGE]

Unless you use VARDEF=DF, which is the default variance divisor, LCLM is set to missing.

UCLM
is the one-sided confidence limit above the mean. The one-sided [IMAGE]percent confidence interval for the mean has the upper limit

[IMAGE]

Unless you use VARDEF=DF, which is the default variance divisor, UCLM is set to missing.


Using Weights
For more information on using weights and an example, see WEIGHT .


Data Requirements for Summarization Procedures
The following are the minimal data requirements to compute unweighted statistics and do not describe recommended sample sizes. Statistics are reported as missing if VARDEF=DF (the default) and these requirements are not met:


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.