Syntax for Modify and
SPSS allows you to modify the values of existing
variables as well as create new variables based on
transformations of those variables.
- Use the RECODE command to change the values
of a particular variable.
- Use the COMPUTE command to create a new
variable based on arithmetic or logical
transformations of an existing variable or
creates a new variable from a
combination or transformation of existing
- Suppose you have these variables,
INCOME99 and INCOME89 and want to create a new variable,
NETCHANGE. This command computes the net change in income
between 1999 and 1989:
- COMPUTE NETCHANGE= INCOME99 -
- You should then label the variable
to know what you've computed:
- VARIABLE LABELS
- 'Net Change in personal
income in 1989 1999'.
- To express this change in
percentage terms specify:
- VARIABLE LABELS
- 'Pct Change CDBG
- COMPUTE allows any combination of arithmetic
operators and numeric constants on the right side of the
equals sign. Arithmetic operations include:
- + Addition
- * Multiplication
- - Subtraction
- / Division
- ** Exponentiation
- Insert blanks before and after an operator to improve
- Use parentheses to control the order of
- You may also use numeric, arithmetic, and statistical
functions with the COMPUTE command.
changes the coding scheme of an existing variable on a
value-by-value basis or for a range of values.
- For example: This command changes the coding order
for CITYTYPE from 51="Central City," 52="Non-Central
City," and 61="Urban County" to 1, 2, and 3:
- RECODE CITYTYPE (51=1) (52=2)
- VALUE LABELS CITYTYPE 1
- 2 'Non-Central City'
3 'Urban County'.
- The thru subcommand enables recoding cases
from one value through another:
- RECODE AGE (18 thru 35=1) (36
thru 60=2) (61 thru 99=3).
VALUE LABELS AGE 1 'Young' 2
'middle age' 3 'Old'.
computes a new variable for a case after testing the case
for a specific condition
IF ([any varname]
Consider these examples:
IF (BIRTH GT 1950) AGE =
IF (BIRTH LE 1950 and BORN GE 1900) AGE = 2.
IF (BIRTH LT 1900) AGE = 3.
The above commands would produce codes that might be
VALUE LABELS AGE
1 'Born after 1950'
2 'Born in 1900-1950'
3 'Born before 1900'.
The arithmetic expressions >, <, = can be used
in place of the logical expressions GT, LT, and EQ. The
expression LE means "less than or equal to" and GE means
"greater than or equal to."
Extracts only those cases that pass the test for the
SELECT IF ([any
- Consider these examples:
- SELECT IF (BIRTH GT
for analysis only respondents born after
- IF (BIRTH LE 1950 and BORN
for analysis only respondents born between 1900