Hallo, ich habe ein Problem beim generieren 4 neuer Variablen aus meinem Datensatz. Ich möchte parenting styles (ps) aus verschieden variablen mit mehreren Ausprägungen definieren. Z.B. sind loben, schimpfen Variablen mit Ausprägungen von 1-5 (die je nie, selten, gelegentlich, oft, sehr oft entsprechen) und Benehmen und Sparsamkeit (je dummies mit ja und nein also 1 und 0). Jetzt möchte ich die neuen Variablen generieren. Hierfür kann ps_1 z.B. bei loben die Ausprägungen 1,2 oder 3 annehmen bei schimpfen 4 oder 5, bei Benehmen 1 und Sparsamkeit 1, allerdings muss Sparsamkeit = 1 nicht unbedingt erfüllt sein, damit ps_1 zutreffen soll. Nun habe ich das Problem, dass mein Code für alle ps_1 bis ps_4 für alle Beobachtungen 1 ausgegeben hat, obwohl die Definitionen im Code unterschiedlich sind? Kann hier jemand helfen oder einen Fehler sehen ? Hier ein Teil des Codes:
gen ps_an = 0 if p0_manners == 0| p0_independent == 0| p0_diligence == 0 | p0_responsible == 0 | p0_frugality == 0 & p0_determined == 0 | p0_selfless == 0 &p0_obedient == 0 & p0_affection == 4 | p0_affection == 5 | p0_praise == 4 | p0_praise == 5 & p0_criticism == 1 | p0_criticism == 2 & p0_punishment == 4 | p0_punishment == 5 & p0_comforting == 4 | p0_comforting == 5 & p0_consistency == 3 | p0_consistency == 4 | p0_consistency == 5 & p0_yelling == 1 | p0_yelling == 2 & p0_rigor == 4 | p0_rigor == 5 & p0_threaten == 4 | p0_threaten == 5 & p0_normgirl_ch1 == 1 | p0_normgirl_ch1 == 2 | p0_normgirl_ch2 == 1 | p0_normgirl_ch2 == 2 |p0_normgirl_ch3 == 1 | p0_normgirl_ch3 == 2 | p0_normgirl_ch4 == 1 | p0_normgirl_ch4 == 2 | p0_normgirl_ch5 == 1 | p0_normgirl_ch5 == 2 | p0_normboys_ch1 == 1 | p0_normboys_ch1 == 2 | p0_normboys_ch2 == 1 | p0_normboys_ch2 == 2 | p0_normboys_ch3 == 1 | p0_normboys_ch3 == 2 | p0_normboys_ch4 == 1 | p0_normboys_ch4 == 2 | p0_normboys_ch5 == 1 | p0_normboys_ch5 == 2
replace ps_an = 1 if p0_manners == 1 | p0_independent == 1| p0_diligence == 1 | p0_responsible == 1 | p0_frugality == 1 & p0_determined == 1 | p0_selfless == 1 &p0_obedient == 1 & p0_affection == 1 | p0_affection == 2 | p0_affection == 3 | p0_praise == 1 | p0_praise == 2 | p0_praise == 3 & p0_criticism == 5 | p0_criticism == 4 | p0_criticism == 3 & p0_punishment == 1 | p0_punishment == 2 | p0_punishment == 3 & p0_comforting == 1 | p0_comforting == 2 | p0_comforting == 3 & p0_consistency == 1 | p0_consistency == 2 & p0_yelling == 5 | p0_yelling == 4 | p0_yelling == 3 & p0_rigor == 1 | p0_rigor == 2 | p0_rigor == 3 & p0_threaten == 1 | p0_threaten == 2 | p0_threaten == 3 & p0_normgirl_ch1 == 3 | p0_normgirl_ch1 == 4 | p0_normgirl_ch1 == 5 | p0_normgirl_ch2 == 3 | p0_normgirl_ch2 == 4 | p0_normgirl_ch2 == 5 |p0_normgirl_ch3 == 3 | p0_normgirl_ch3 == 4 | p0_normgirl_ch3 == 5 | p0_normgirl_ch4 == 3 | p0_normgirl_ch4 == 4 | p0_normgirl_ch4 == 5 | p0_normgirl_ch5 == 3 | p0_normgirl_ch5 == 4 | p0_normgirl_ch5 == 5 | p0_normboys_ch1 == 3 | p0_normboys_ch1 == 4 |p0_normboys_ch1 == 5 | p0_normboys_ch2 == 3 | p0_normboys_ch2 == 4 | p0_normboys_ch2 == 5 | p0_normboys_ch3 == 3 | p0_normboys_ch3 == 4 | p0_normboys_ch3 == 5 | p0_normboys_ch4 == 3 | p0_normboys_ch4 == 4 | p0_normboys_ch4 == 5 | p0_normboys_ch5 == 3 | p0_normboys_ch5 == 4 | p0_normboys_ch5 == 5
gen ps_av = 0 if p0_manners == 0 | p0_independent == 0 | p0_diligence == 0 | p0_responsible == 0 | p0_imagine == 0 | p0_tolerance == 0 | p0_frugality == 0 | p0_determined == 0 | p0_selfless == 0 | p0_obedient == 0 & p0_normgirl_ch1 == 4 | p0_normgirl_ch1 == 5 | p0_normgirl_ch2 == 4 | p0_normgirl_ch2 == 5 | p0_normgirl_ch3 == 4 | p0_normgirl_ch3 == 5 | p0_normgirl_ch4 == 4 | p0_normgirl_ch4 == 5 | p0_normgirl_ch5 == 4 | p0_normgirl_ch5 == 5 | p0_normboys_ch1 == 4 | p0_normboys_ch1 == 5 | p0_normboys_ch2 == 4 | p0_normboys_ch2 == 5 | p0_normboys_ch3 == 4 | p0_normboys_ch3 == 5 |p0_normboys_ch4 == 4 | p0_normboys_ch4 == 5 | p0_normboys_ch5 == 4 | p0_normboys_ch5 == 5 & p0_affection == 3 | p0_affection == 1 | p0_affection == 2 & p0_praise == 1 | p0_praise == 2 & p0_criticism == 4 | p0_criticism == 5 & p0_punishment == 4 | p0_punishment == 5 & p0_comforting == 1 | p0_comforting == 2 & p0_consistency == 4 | p0_consistency == 5 & p0_yelling == 4 | p0_yelling == 5 & p0_rigor == 4 | p0_rigor == 5 & p0_threaten == 4 | p0_threaten == 5
replace ps_av = 1 if p0_manners == 1| p0_independent == 1| p0_diligence == 1 | p0_responsible == 1 | p0_imagine == 1 | p0_tolerance == 1 | p0_frugality == 1 | p0_determined == 1 | p0_selfless == 1 |p0_obedient == 1 & p0_normgirl_ch1 == 1 | p0_normgirl_ch1 == 2 | p0_normgirl_ch1 == 3 |p0_normgirl_ch2 == 1 | p0_normgirl_ch2 == 2 | p0_normgirl_ch2 == 3 | p0_normgirl_ch3 == 1 | p0_normgirl_ch3 == 2 | p0_normgirl_ch3 == 3 | p0_normgirl_ch4 == 1 | p0_normgirl_ch4 == 2 | p0_normgirl_ch4 == 3|p0_normgirl_ch5 == 1 | p0_normgirl_ch5 == 2 | p0_normgirl_ch5 == 3 | p0_normboys_ch1 == 1 | p0_normboys_ch1 == 2 |p0_normboys_ch1 == 3 | p0_normboys_ch2 == 1 | p0_normboys_ch2 == 2 | p0_normboys_ch2 == 3 | p0_normboys_ch3 == 1 | p0_normboys_ch3 == 2 | p0_normboys_ch3 == 3 |p0_normboys_ch4 == 1 | p0_normboys_ch4 == 2 | p0_normboys_ch4 == 3 | p0_normboys_ch5 == 1 | p0_normboys_ch5 == 2 | p0_normboys_ch5 == 3 & p0_affection == 3 | p0_affection == 5 | p0_affection == 4 & p0_praise == 5 | p0_praise == 4 | p0_praise == 3 & p0_criticism == 1 | p0_criticism == 2 | p0_criticism == 3 & p0_punishment == 1 | p0_punishment == 2 | p0_punishment == 3 & p0_comforting == 5 | p0_comforting == 4 | p0_comforting == 3 & p0_consistency == 1 | p0_consistency == 2 | p0_consistency == 3 & p0_yelling == 1 | p0_yelling == 2| p0_yelling == 3 & p0_rigor == 1 | p0_rigor == 2 | p0_rigor == 3 & p0_threaten == 1 | p0_threaten == 2 | p0_threaten == 3
Ich wäre sehr glücklich über Hilfe ! Danke schon mal.