Commonly, most or all data in a case come from an input file, read with a command such as DATA LIST or GET, but data can also be generated with transformations such as COMPUTE. In the latter case the question of a datum's “initial value” can arise. For example, the value of a piece of generated data can recursively depend on its own value:
COMPUTE X = X + 1.
Another situation where the initial value of a variable arises is when
its value is not set at all for some cases, e.g. below,
set only for the first 10 cases:
DO IF #CASENUM <= 10. + COMPUTE Y = 1. END IF.
By default, the initial value of a datum in either of these situations is the system-missing value for numeric values and spaces for string values. This means that, above, X would be system-missing and that Y would be 1 for the first 10 cases and system-missing for the remainder.
PSPP also supports retaining the value of a variable from one case to another, using the LEAVE command (see LEAVE). The initial value of such a variable is 0 if it is numeric and spaces if it is a string. If the command `LEAVE X Y' is appended to the above example, then X would have value 1 in the first case and increase by 1 in every succeeding case, and Y would have value 1 for the first 10 cases and 0 for later cases.
The LEAVE command has no effect on data that comes from an input file or whose values do not depend on a variable's initial value.
The value of scratch variables (see Scratch Variables) are always left from one case to another.
The following functions work with a variable's leave status.
Returns true if var's value is to be retained from case to case, false if it is reinitialized to system-missing or spaces.
If leave is true, marks var to be left from case to case; if leave is false, marks var to be reinitialized for each case.
If var is a scratch variable, leave must be true.