When variables are read with
a SET, MERGE, or UPDATE statement, SAS sets the values to missing
only before the first iteration of the DATA step. (If you use a BY
statement, the variable values are also set to missing when the BY
group changes.) The variables retain their values until new values
become available (for example, through an assignment statement or
through the next execution of the SET, MERGE, or UPDATE statement).
Variables created with options in the SET, MERGE, and UPDATE statements
also retain their values from one iteration to the next.
When all rows in a data
set in a match-merge operation (with a BY statement) are processed,
the variables in the output data set retain their values as described
earlier. That is, as long as there is no change in the BY value in
effect when all of the rows in the data set have been processed, the
variables in the output data set retain their values from the final observation.
FIRST.variable and LAST.variable, the automatic variables that are
generated by the BY statement, both retain their values. Their initial
value is 1.
When the BY value changes,
the variables are set to missing and remain missing because the data
set contains no additional observations to provide replacement values. When
all of the rows in a data set in a one-to-one merge operation (without
a BY statement) have been processed, the variables in the output data
set are set to missing and remain missing.