Variable redefinition

<< Click to Display Table of Contents >>

Navigation:  User guide > Variables >

Variable redefinition

The values of all fields, spreadfields, cols and colbins are replaced when a new raw data record is read into the relevant data locations.

You may also set new values for fields, spreadfields, cols and colbins as required. This is generally only done when punching out a new raw data set (recode).

The values of all other variables are set to zero when START DATA is executed, except that temporary variables (names beginning with X) are not set if the PRESERVE TEMPORARY command has been specified, nor are reserved variables cleared. A ZERO command may be used to clear the values of any variables.

A variable may be redefined as often as required, but a redefinition may not alter a variable's type or length.

Each definition of a variable replaces the contents of those records that reach it in the flow of execution (do not bypass the command as a result of FILTER, IF, UL, or GO TO commands).

The contents of variables can be updated using a self-referring expression for example, di $i=$i+1,. Self-reference is not allowed for the first definition of a variable.

IF, ELSE and GO TO commands may be used so that different definitions of a variable do not overwrite each other.

The M (make) command may be used to "patch" svars, mvars and cols - that is to add or delete codes or responses, without altering the rest of the contents.