This DATA step produces a SAS data set with the following variable values:
OBS X Y
1 4 .
2 1 2
3 3 .
4 1 2
When X equals 1, the value of Y is set to 2. Since no other statements set Y's value when
X is not equal to 1, Y remains missing (.) for those observations.
When Reading a SAS Data Set
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.
When Missing Values Are Generated by SAS
Propagation of Missing Values in Calculations
SAS assigns missing values to prevent problems from arising. If you use a missing value
in an arithmetic calculation, SAS sets the result of that calculation to missing. Then, if
you use that result in another calculation, the next result is also missing. This action is
called propagation of missing values. SAS prints notes in the log to notify you which
arithmetic expressions have missing values and when they were created. However,
processing continues.
Invalid Operations
SAS prints a note in the log and assigns a missing value to the result if you try to
perform an invalid operation, such as the following:
• dividing by zero
• taking the logarithm of zero
When Missing Values Are Generated by SAS 87