Previous Page | Next Page

SAS Elementary Statistics Procedures

Keywords and Formulas


Simple Statistics

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:

[equation]

is the nonmissing value of the analyzed variable for observation i.

[equation]

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

[equation]

is the weight that is associated with [equation] if you use a WEIGHT statement. The base procedures automatically exclude the values of [equation] 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, then the procedure also excludes those values of [equation] 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 [equation] for all i.

[equation]

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

[equation]

is the mean

[equation]

[equation]

is the variance

[equation]

where [equation] is the variance divisor (the VARDEF= option) that you specify in the PROC statement. Valid values are as follows:
When VARDEF= [equation] equals . . .
N [equation]
DF [equation]
WEIGHT [equation]
WDF [equation]

The default is DF.

[equation]

is the standardized variable

[equation]

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 X



of the variance
X




of quantiles
X



Median X X X X X
Mode X X X X

Percentiles/Deciles/Quartiles X X X X

t test






for mean=0 X X X X
X

for mean= [equation]
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

[equation]

CV

is the percent coefficient of variation, computed as

[equation]

KURTOSIS | KURT

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

[equation]

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

[equation]

When VARDEF=N, the kurtosis is computed as

[equation]

and the weighted kurtosis is computed as

[equation]

where [equation] is [equation]. The formula is invariant under the transformation [equation]. 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 [equation].

MEAN

is the arithmetic mean [equation].

MIN

is the minimum value of [equation].

MODE

is the most frequent value of [equation].

Note:   When QMETHOD=P2, PROC REPORT, PROC MEANS, and PROC TABULATE do not compute MODE.  [cautionend]

N

is the number of [equation] values that are not missing. Observations with [equation] less than one and [equation] equal to missing or [equation] (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 [equation] values that are missing. Observations with [equation] less than one and [equation] equal to missing or [equation] (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

[equation]

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

[equation]

When VARDEF=N, the skewness is computed as

[equation]

and the weighted skewness is computed as

[equation]

The formula is invariant under the transformation [equation]. 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, [equation].

STDERR | STDMEAN

is the standard error of the mean, computed as

[equation]

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

is the sum, computed as

[equation]

SUMWGT

is the sum of the weights, [equation], computed as

[equation]

USS

is the uncorrected sum of squares, computed as

[equation]

VAR

is the variance [equation].


Quantile and Related Statistics

The keywords for quantiles 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

[equation]

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

[equation]

Here, QNTLDEF= 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

[equation]

where [equation] is the weight associated with [equation] and [equation] is the sum of the weights. When the observations have identical weights, the weighted percentiles are the same as the unweighted percentiles with QNTLDEF=5.
Methods for Computing Quantile Statistics
QNTLDEF= Description Formula
1 weighted average at [equation] [equation]

where [equation] is taken to be [equation]
2 observation numbered closest to [equation] [equation]
if [equation]
[equation]
if [equation] and [equation] is even
[equation]
if [equation] and [equation] is odd
where i is the integer part of [equation]
3 empirical distribution function [equation]
if [equation]
[equation]
if [equation]
4 weighted average aimed at [equation] [equation]

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


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 [equation] and is calculated as

[equation]

By default, [equation] is equal to zero. You can use the MU0= option in the PROC UNIVARIATE statement to specify [equation]. 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 [equation] 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 | PRT

is the two-tailed p-value for Student's t statistic, T, with [equation] degrees of freedom. This value 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

The keywords for confidence limits are

CLM

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

[equation]

where [equation] is [equation], [equation] is the ( [equation]) critical value of the Student's t statistics with [equation] degrees of freedom, and [equation] 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 [equation]percent confidence interval for the mean has the lower limit

[equation]

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 [equation]percent confidence interval for the mean has the upper limit

[equation]

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 the following requirements are not met:

Previous Page | Next Page | Top of Page