SPSS: How do IF, THEN, ELSE statements work?

Conditional syntax is easiest to explain with an example.

Example

DO IF (GroupNumber=1 and Location=1).
  COMPUTE Condition=1.
ELSE IF (GroupNumber=1 and Location=2).
  COMPUTE Condition=2.
ELSE IF (GroupNumber=2 and Location=1).
  COMPUTE Condition = 3.
ELSE IF (GroupNumber=2 and Location=2).
  COMPUTE Condition=4.
END IF.
EXECUTE.
 
VALUE LABELS
  Condition 1 "Control Group in Cuba" 2 "Control Group in Miami" 3 "Experimental Group in Cuba" 4 "Experimental Group in Miami".
EXECUTE.

Further Reading

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>