Path: janda.org/c10
> Overview
of SPSS
>
Modify and
Recode

Statistical
Package
for the
Social
Sciences
Syntax for Modify and
Recode Commands

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
variables.

COMPUTE

creates a new variable from a
combination or transformation of existing
variables.

 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 
INCOME89
 You should then label the variable
to know what you've computed:
 VARIABLE LABELS
NETCHANGE
 'Net Change in personal
income in 1989 1999'.
 To express this change in
percentage terms specify:
 COMPUTE
PCTCHANGE=((INCOME99INCOME89)/INCOME89)*100
 VARIABLE LABELS
PCTCHANGE
 'Pct Change CDBG
Allocation, 198589'
 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
readability .
 Use parentheses to control the order of
calculation.
 You may also use numeric, arithmetic, and statistical
functions with the COMPUTE command.

RECODE

changes the coding scheme of an existing variable on a
valuebyvalue basis or for a range of values.

 For example: This command changes the coding order
for CITYTYPE from 51="Central City," 52="NonCentral
City," and 61="Urban County" to 1, 2, and 3:
 RECODE CITYTYPE (51=1) (52=2)
(61=3)
 VALUE LABELS CITYTYPE 1
'Central City'
 2 'NonCentral 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'.

IF

computes a new variable for a case after testing the case
for a specific condition

IF ([any varname]
[logical expression])
[any varname]=[arithmetic
expression].
Consider these examples:
IF (BIRTH GT 1950) AGE =
1.
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
labeled:
VALUE LABELS AGE
1 'Born after 1950'
2 'Born in 19001950'
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."

SELECT IF

Extracts only those cases that pass the test for the
specified condition

SELECT IF ([any
varname] [logical
expression]).

 Consider these examples:
 SELECT IF (BIRTH GT
1950).
 [Selects
for analysis only respondents born after
1950.]

 IF (BIRTH LE 1950 and BORN
GE 1900).
 [Selects
for analysis only respondents born between 1900
and 1950.]
