Data editing > Changing the contents of a variable > Assignment statements
 
Assignment statements
An assignment statement normally means ‘put the specified information into the given variable overwriting anything already in that variable’. It can be used with any type of variable to perform any of the following tasks:
to copy codes from one column into another
to replace certain codes in one column with those from a second column
to assign the value of an arithmetic expression to a variable
to copy codes from groups of columns into another column using the logical operators and, or and xor.
The basic format of any assignment statement is:
variable=item
item defines what is to be copied into the variable.
Comments can be identified by an uppercase C in column 1. If the first variable in your statement starts with a C, make sure that you type it in lower case otherwise the whole line is read as a comment and is ignored. For example:
c(15,16)=$12$
is correct, but
C(15,16)=$12$
is read as a comment even though the syntax is correct.
Alternatively, you can precede assignment statements with the word set, thus:
set c(15,16)=$12$
In this documentation, set is omitted from all such statements.
See
Copying codes
Partial column replacement
Storing arithmetic values
Assignment with and, or and xor
See also
Changing the contents of a variable