Seite 1 von 1

IF Bedinung mit mehreren Conditions

BeitragVerfasst: Fr 11. Feb 2022, 16:51
von spss_noob
Hallo liebe Leute,

ich habe 9 dichotome Variablen (1, -99) und möchte diese zu einer Variable mit neun Variablen umcodieren. Dabei sollen nur diese Fälle berücksichtigt werden, die bei genau einer der neun Variablen eine gültige Antwort gegeben haben (1). Dies ist meine Syntax:
IF (q0001_0001 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 1.
IF (q0001_0002 = 1 & (q0001_0001 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 2.
IF (q0001_0003 = 1 & (q0001_0002 = -99 & q0001_0001 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 3.
IF (q0001_0004 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0001 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 4.
IF (q0001_0005 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0001 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 5.
IF (q0001_0006 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0001 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 6.
IF (q0001_0007 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0001 = -99 & q0001_0008 = -99 & q0001_0009 = -99)) bundesland = 7.
IF (q0001_0008 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0001 = -99 & q0001_0009 = -99)) bundesland = 8.
IF (q0001_0009 = 1 & (q0001_0002 = -99 & q0001_0003 = -99 & q0001_0004 = -99 & q0001_0005 = -99 & q0001_0006 = -99 & q0001_0007 = -99 & q0001_0008 = -99 & q0001_0001 = -99)) bundesland = 9.
EXECUTE.

Leider funktioniert das so anscheinend nicht. Fälle die etwa bei q0001_0001 und q0001_0002 = 1 sind werden mit 1 in der neuen Variable codiert.
Ich wäre sehr dankbar für eure Hilfe!

Liebe Grüße

Re: IF Bedinung mit mehreren Conditions

BeitragVerfasst: Fr 11. Feb 2022, 19:21
von ponderstibbons
-99 ist als missing value definiert.

IF(NVALID(q0001_0001 to q0001_0009) = 1 AND (q0001_0001=1) ) bundesland = 1 .

etc.

mit freundlichen Grüßen

PonderStibbons

Re: IF Bedinung mit mehreren Conditions

BeitragVerfasst: Sa 12. Feb 2022, 09:31
von strukturmarionette
HI,

- die Anzahl der 1er zunächst auszählen und wenn de Summe 1 ist, dann die neue Variable füllen

Gruß
S.