COMPUTE variable = expression.
COMPUTE vector(index) = expression.
COMPUTE assigns the value of an expression to a target
variable. For each case, the expression is evaluated and its value
assigned to the target variable. Numeric and string
variables may be assigned. When a string expression's width differs
from the target variable's width, the string result of the expression
is truncated or padded with spaces on the right as necessary. The
expression and variable types must match.
For numeric variables only, the target variable need not already
exist. Numeric variables created by
COMPUTE are assigned an
F8.2 output format. String variables must be declared before
they can be used as targets for
The target variable may be specified as an element of a vector (see VECTOR). In this case, an expression index must be specified in parentheses following the vector name. The expression index must evaluate to a numeric value that, after rounding down to the nearest integer, is a valid index for the named vector.
COMPUTE to assign to a variable specified on
(see LEAVE) resets the variable's left state. Therefore,
LEAVE should be specified following
COMPUTE, not before.
COMPUTE is a transformation. It does not cause the active dataset to be
COMPUTE is specified following
(see TEMPORARY), the
LAG function may not be used