Hi all,
I am new to SPSS-Syntax. I will appreciate if any of you can help me with the following programming.
I have a variable 'group' with 3 values 1 2 3. I would like to compute another variable 'group2'
from 'group' with another condition on another variable 'age'. The condition is:
I want to keep the first value of 'group' as it is if age <=5 else the value should be changed to 0.
The second value (2) of the 'group' should be as it is if age=6 else 2 should be set to zero. The 3rd value (3) of the 'group' should be as it is if age=7 else 3 should be set to zero. How do I write the SPSS-syntax for this task?
Thank you.
soma
spss syntax
-
drfg2008
- Beiträge: 2391
- Registriert: 06.02.2011, 19:58
re
Code: Alles auswählen
input program.
loop case =1 to 1000 by 1.
end case.
end loop.
end file.
end input program.
EXECUTE.
COMPUTE group=RND(RV.UNIFORM(1,3)).
COMPUTE age=RND(RV.UNIFORM(1,7)).
EXECUTE.
IF (group EQ 1 and age <= 5) group2 = 1.
IF (group EQ 2 and age EQ 6) group2 = 2.
IF (group EQ 3 and age EQ 7) group2 = 3.
RECODE group2 (SYSMIS=0).
EXECUTE.
SORT CASES BY group(A) age(A).drfg2008



