Erin Holloway
2020-08-20 06:08:06 UTC
So I have these overly complicated IF statements and I need to run to compute a new variable. But I need to do the same computation for 30 occasions. So basically I need to end up with 30 new variables- Participation_1 to Participation_30. The other variable names change the same way _1 to _30.
I assume its a loop? not sure how to write it though?
The variables are all numeric
DO IF (MISSING(CurrentlyStudying_status_1) AND MISSING(CurrentlyEmployed_1) AND MISSING(LookingForWork_1)).
COMPUTE Participation_1 = $SYSMIS.
ELSE IF (CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 0 AND LookingForWork_1 = 6).
COMPUTE Participation_1 = 0.
ELSE IF (CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 0 AND LookingForWork_1 = 9).
COMPUTE Participation_1 = 1.
ELSE IF (CurrentlyEmployed_1 = 2 AND CurrentlyStudying_status_1 = 0
OR CurrentlyEmployed_1 = 1 AND CurrentlyStudying_status_1 = 0
OR CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 1).
COMPUTE Participation_1 = 2.
ELSE IF (CurrentlyEmployed_1 = 2 AND CurrentlyStudying_status_1 = 1
OR CurrentlyEmployed_1 = 1 AND CurrentlyStudying_status_1 = 1
OR CurrentlyEmployed_1 = 3 OR CurrentlyStudying_status_1 = 1).
COMPUTE Participation_1 = 3.
END IF.
EXECUTE.
I assume its a loop? not sure how to write it though?
The variables are all numeric
DO IF (MISSING(CurrentlyStudying_status_1) AND MISSING(CurrentlyEmployed_1) AND MISSING(LookingForWork_1)).
COMPUTE Participation_1 = $SYSMIS.
ELSE IF (CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 0 AND LookingForWork_1 = 6).
COMPUTE Participation_1 = 0.
ELSE IF (CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 0 AND LookingForWork_1 = 9).
COMPUTE Participation_1 = 1.
ELSE IF (CurrentlyEmployed_1 = 2 AND CurrentlyStudying_status_1 = 0
OR CurrentlyEmployed_1 = 1 AND CurrentlyStudying_status_1 = 0
OR CurrentlyEmployed_1 = 0 AND CurrentlyStudying_status_1 = 1).
COMPUTE Participation_1 = 2.
ELSE IF (CurrentlyEmployed_1 = 2 AND CurrentlyStudying_status_1 = 1
OR CurrentlyEmployed_1 = 1 AND CurrentlyStudying_status_1 = 1
OR CurrentlyEmployed_1 = 3 OR CurrentlyStudying_status_1 = 1).
COMPUTE Participation_1 = 3.
END IF.
EXECUTE.