Overview (COMPUTE command)
COMPUTE
creates
new numeric variables or modifies the values of existing string or
numeric variables. The variable named on the left of the equals sign
is the target variable.
The variables, constants, and functions on the right side of the equals
sign form an assignment expression. For
a complete discussion of functions, see Transformation Expressions.
Numeric Transformations
Numeric variables can be created or modified
with COMPUTE
. The assignment
expression for numeric transformations can include combinations of
constants, variables, numeric operators, and functions.
String transformations
String
variables can be modified but cannot be created with COMPUTE
. However, a new string variable
can be declared and assigned a width with the STRING
command and then assigned values by COMPUTE
. The assignment expression can include
string constants, string variables, and any of the string functions.
All other functions are available for numeric transformations only.
Basic specification
The basic specification is a target variable, an equals sign (required), and an assignment expression.