The REG Procedure |
REWEIGHT Statement |
The REWEIGHT statement interactively changes the weights of observations that are used in computing the regression equation. The REWEIGHT statement can change observation weights, or set them to zero, which causes selected observations to be excluded from the analysis. When a REWEIGHT statement sets observation weights to zero, the observations are not deleted from the data set. More than one REWEIGHT statement can be used. The requests from all REWEIGHT statements are applied to the subsequent statements. Each use of the REWEIGHT statement modifies the MODEL label.
The model and corresponding statistics are not recomputed after a REWEIGHT statement. For example, consider the following statements:
reweight r.>0; reweight r.>0;
The second REWEIGHT statement does not exclude any additional observations since the model is not recomputed after the first REWEIGHT statement. Either use a REFIT statement to explicitly refit the model, or implicitly refit the model by following the REWEIGHT statement with any other interactive statement except a PAINT statement or another REWEIGHT statement.
The REWEIGHT statement cannot be used if a TYPE=CORR, TYPE=COV, or TYPE=SSCP data set is used as an input data set to PROC REG. Note that the syntax used in the REWEIGHT statement is the same as the syntax in the PAINT statement.
The syntax of the REWEIGHT statement is described in the following sections.
For detailed examples of using this statement, see the section Reweighting Observations in an Analysis.
Condition is used to find observations to be reweighted. The syntax of condition is
variable compare value
or
variable compare value logical variable compare value
where
is one of the following:
a variable name in the input data set
OBS., which is the observation number
keyword., where keyword is a keyword for a statistic requested in the OUTPUT statement. The keyword specification is applied to all dependent variables in the model.
is an operator that compares variable to value. Compare can be any one of the following: <, <=, >, >=, =, =. The operators LT, LE, GT, GE, EQ, and NE, respectively, can be used instead of the preceding symbols. Refer to the "Expressions" chapter in SAS Language Reference: Concepts for more information about comparison operators.
gives an unformatted value of variable. Observations are selected to be reweighted if they satisfy the condition created by variable compare value. Value can be a number or a character string. If value is a character string, it must be eight characters or less and must be enclosed in quotes. In addition, value is case-sensitive. In other words, the following two statements are not the same:
reweight name='steve';
reweight name='Steve';
is one of two logical operators. Either AND or OR can be used. To specify AND, use AND or the symbol &. To specify OR, use OR or the symbol |.
Here are some examples of the variable compare value form:
reweight obs. le 10; reweight temp=55; reweight type='new';
Here are some example of the variable compare value logical variable compare value form:
reweight obs.<=10 and residual.<2; reweight student.<-2 or student.>2; reweight name='Mary' | name='Susan';
Instead of specifying condition, you can use the ALLOBS option to select all observations. This is most useful when you want to restore the original weights of all observations. For example,
reweight allobs / reset;
resets weights for all observations and uses all observations in the subsequent analysis. Note that
reweight allobs;
specifies that all observations be excluded from analysis. Consequently, using ALLOBS is useful only if you also use one of the options discussed in the following section.
The following options can be used when either a condition, ALLOBS, or nothing is specified before the slash. If only an option is listed, the option applies to the observations selected in the previous REWEIGHT statement, not to the observations selected by reapplying the condition from the previous REWEIGHT statement. For example, consider the following statements:
reweight r.>0 / weight=0.1; refit; reweight;
The second REWEIGHT statement excludes from the analysis only those observations selected in the first REWEIGHT statement. No additional observations are excluded even if there are new observations that meet the condition in the first REWEIGHT statement.
Note:Options are not available when either the UNDO or STATUS option is used.
suppresses the display of the selected observation numbers. If you omit the NOLIST option, a list of observations selected is written to the log.
resets the observation weights to their original values as defined by the WEIGHT statement or to WEIGHT=1 if no WEIGHT statement is specified. For example,
reweight / reset;
resets observation weights to the original weights in the data set. If previous REWEIGHT statements have been submitted, this REWEIGHT statement applies only to the observations selected by the previous REWEIGHT statement. Note that, although the RESET option does reset observation weights to their original values, it does not cause the model and corresponding statistics to be recomputed.
changes observation weights to the specified nonnegative real number. If you omit the WEIGHT= option, the observation weights are set to zero, and observations are excluded from the analysis. For example:
reweight name='Alan'; \Codecomment{...other interactive statements} reweight / weight=0.5;
The first REWEIGHT statement changes weights to zero for all observations with name=’Alan’, effectively deleting these observations. The subsequent analysis does not include these observations. The second REWEIGHT statement applies only to those observations selected by the previous REWEIGHT statement, and it changes the weights to 0.5 for all the observations with NAME=’Alan’. Thus, the next analysis includes all original observations; however, those observations with NAME=’Alan’ have their weights set to 0.5.
If you omit condition and the ALLOBS options, you can specify one of the following options.
writes to the log the observation’s number and the weight of all reweighted observations. If an observation’s weight has been set to zero, it is reported as deleted. However, the observation is not deleted from the data set, only from the analysis.
undoes the changes made by the most recent REWEIGHT statement. Weights might be, but are not necessarily, reset. For example, consider the following statements:
reweight student.>2 / weight=0.1; reweight; reweight undo;
The first REWEIGHT statement sets the weights of observations that satisfy the condition to 0.1. The second REWEIGHT statement sets the weights of the same observations to zero. The third REWEIGHT statement undoes the second, changing the weights back to 0.1.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.