Hey everyone,
I would like to create a variable which is 0 if at least one of the household members completed at least 5 years of schooling. It is supposed to turn 1 if all household members have less than 5 years of education.
Here is the code I wrote is the following:
What I now get is that the variabel is 1 if one or more members of the household are <5, but what I need is that the variable gets 1 if all members are <5.
I would like to create a variable which is 0 if at least one of the household members completed at least 5 years of schooling. It is supposed to turn 1 if all household members have less than 5 years of education.
Here is the code I wrote is the following:
Code:
gen education = 0 foreach var in hv108_01 hv108_02 hv108_03 hv108_04 hv108_05 hv108_06 hv108_07 hv108_08 hv108_09 hv108_10 hv108_11 hv108_12 hv108_13 hv108_14 hv108_15 hv108_16 hv108_17 hv108_18 hv108_19 hv108_20 hv108_21 hv108_22 hv108_23 hv108_24 hv108_25 hv108_26 hv108_27 hv108_28 hv108_29 hv108_30 hv108_31 hv108_32 hv108_33 hv108_34 hv108_35 hv108_36 hv108_37 { replace education = 1 if `var' < 5 }
Comment