ARCHIVED: In SPSS, how do I collapse and recode a continuous variable?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

In SPSS, you have two options for collapsing and recoding continuous variables: the IF command and the RECODE command.

The IF command

Suppose you have a variable score that you need to collapse into five distinct categories in a new variable grade:

  IF (score > 90) grade=4. 	
  IF (score <=90 AND score >= 80) grade=3. 	
  IF (score <80 AND score >=70) grade=2. 	
  IF (score <70 AND score >=60) grade=1. 	
  IF (score <60) grade=0. 

These conditions break the variable score into five categories. For example, scores ranging from 80 to 90 are coded as 3 in the new variable.

The RECODE command

For the example above, you would use the following:

  RECODE
    score
    (80 thru 90=3) (70 thru 80=2) (60 thru 70=1) (LOWEST thru 60=0) (90 thru HIGHEST=4) 
    INTO  grade.
    EXECUTE.

Important: The order of the statements matters; that is, SPSS manipulates the statements in order. Therefore, all subjects having values between 80 and 90 in the variable score will have the value 3 in the new variable grade, and all subjects having values between 70 and 80 (except 80, since it's defined in the previous statement) will have the value 2 in the new variable grade, and so forth.

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document afqo in the Knowledge Base.
Last modified on 2023-05-09 14:39:56.