retains the value of variable for
use in a subsequent observation. The RETAIN statement prevents the
value of the variable from being reinitialized to missing when control
returns to the top of the DATA step.
The RETAIN statement
affects variables that are created in the current DATA step (for example,
variables that are created with an INPUT or assignment statement).
Variables that are read with a SET, MERGE, or UPDATE statement are
retained automatically. Naming them in a RETAIN statement has no effect.
The RETAIN statement
can assign an initial value to a variable. If a variable needs to
have the same value in all observations of a DATA step, then it is
more efficient to put the value in a RETAIN statement rather than
in an assignment statement. SAS assigns the value in the RETAIN statement
when it is compiling the DATA step, but it executes the assignment
statement during each execution of the DATA step.
SET SAS-data-set <END=variable>;
reads from the specified SAS-data-set.
The variable that is specified
in the END= option has the value 0 until SAS is processing the last
observation in the data set. Then the variable has the value 1. SAS
does not include the END= variable in the data set that is being created.
variable + expression;
is called a Sum statement.
It adds the result of expression on
the right side of the plus sign to variable on
the left side of the plus sign, and holds the new value of variable for
use in subsequent observations. The expression can be a numeric variable
or expression. The value of variable is
retained. If the expression is a missing value, variable maintains
its previous value. Before the Sum statement is executed for the
first time, the default value of variable is
0.
The plus sign is required
in the Sum statement. To subtract successive values from a starting
value, add negative values to the Sum variable.