spss syntax

Fragen und Diskussionen rund um die Arbeit mit SPSS. Für allgemeine Statistik-Themen, die nicht mit SPSS zusammenhängen, bitte das Statistik-Forum nutzen.
Antworten
soma
Beiträge: 1
Registriert: 12.06.2012, 15:15

spss syntax

Beitrag von soma »

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
drfg2008
Beiträge: 2391
Registriert: 06.02.2011, 19:58

re

Beitrag von drfg2008 »

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
Anzeige:Statistik und SPSS: Die besten Bücher
Als Buch oder E-Book - Jetzt bestellen
spss datenanalyse
SPSS - Moderne Datenanalyse - Jetzt bestellen!
statistik datenanalyse
Statistik - Der Weg zur Datenanalyse - Jetzt bestellen!
Antworten