The UNIVARIATE Procedure

WEIGHT Statement

  • WEIGHT variable;

The WEIGHT statement specifies numeric weights for analysis variables in the statistical calculations. The UNIVARIATE procedure uses the values w Subscript i of the WEIGHT variable to modify the computation of a number of summary statistics by assuming that the variance of the ith value x Subscript i of the analysis variable is equal to sigma squared divided by w Subscript i, where sigma is an unknown parameter. The values of the WEIGHT variable do not have to be integers and are typically positive. By default, observations that have nonpositive or missing values of the WEIGHT variable are handled as follows:

  • If the value is 0, the observation is counted in the total number of observations.

  • If the value is negative, it is converted to 0, and the observation is counted in the total number of observations.

  • If the value is missing, the observation is excluded from the analysis.

To exclude observations that contain negative and 0 weights from the analysis, specify the EXCLNPWGT option in the PROC UNIVARIATE statement. Note that most SAS/STAT procedures, such as PROC GLM, exclude negative and zero weights by default. The weight variable does not change how the procedure determines the range, mode, extreme values, extreme observations, or number of missing values. When you specify a WEIGHT statement, the procedure also computes a weighted standard error and a weighted version of Student’s t test. The Student’s t test is the only test of location that PROC UNIVARIATE computes when you weight the analysis variables.

When you specify a WEIGHT variable, the procedure uses its values, w Subscript i, to compute weighted versions of the statistics that are provided in the Moments table. For example, the procedure computes a weighted mean x overbar Subscript w and a weighted variance s Subscript w Superscript 2 as

x overbar Subscript w Baseline equals StartFraction sigma summation Underscript i Endscripts w Subscript i Baseline x Subscript i Baseline Over sigma summation Underscript i Endscripts w Subscript i Baseline EndFraction

and

s Subscript w Superscript 2 Baseline equals StartFraction 1 Over d EndFraction sigma summation Underscript i Endscripts w Subscript i Baseline left parenthesis x Subscript i Baseline minus x overbar Subscript w Baseline right parenthesis squared

where x Subscript i is the ith variable value. The divisor d is controlled by the VARDEF= option in the PROC UNIVARIATE statement.

The WEIGHT statement does not affect the determination of the mode, extreme values, extreme observations, or the number of missing values of the analysis variables. However, the weights w Subscript i are used to compute weighted percentiles. The WEIGHT variable has no effect on graphical displays that are produced by the plot statements.

To compute weighted skewness or kurtosis, use VARDEF=DF or VARDEF=N in the PROC statement.

When you use the WEIGHT statement, consider which value of the VARDEF= option is appropriate. For more information, see the VARDEF= option and the calculation of weighted statistics.

If you specify a WEIGHT statement, you cannot specify any of the CIPCTLDF, CIPCTLNORMAL, LOCCOUNT, NORMAL, ROBUSTSCALE, TRIMMED=, and WINSORIZED= options in the PROC UNIVARIATE statement.

You cannot specify the HISTOGRAM, PROBPLOT, or QQPLOT statements with the WEIGHT statement.

Last updated: April 16, 2025