Hi
I want to create four separate dummy variables at household level:
1. No children between 5 and 16 years old in the household
2. All children between 5 and 16 years old are attending school
3. Only some children between 5 and 16 years old are attending school
4. None of the children between 5 and 16 years old are attending school
Following is the data on age and education of each household member.
What I want is to have, for first variable, '1' if the household has no children between 5 and 16 years of age and '0' otherwise, for second variable, '1' if all children between age of 5 and 16 are attending school and '0' othewise and the same for variable 3 and 4. I have used the following code for variable 1, but it puts either '0' or '1' for each hh member who meets the condition. What I want is to have '0' or '1' for the whole household if any one of the member meets the condition.
Thanks
I want to create four separate dummy variables at household level:
1. No children between 5 and 16 years old in the household
2. All children between 5 and 16 years old are attending school
3. Only some children between 5 and 16 years old are attending school
4. None of the children between 5 and 16 years old are attending school
Following is the data on age and education of each household member.
Code:
clear input double hhid float age float yrsedu 101000 50 0 101000 41 0 101000 14 7 101000 17 0 101000 8 0 102000 50 0 102000 42 0 102000 14 7 102000 14 5 102000 18 8 103000 4 0 103000 20 8 103000 28 8 104000 8 0 104000 15 0 104000 29 10 104000 30 10 end label var yrsedu "Years of Education"
Code:
gen all5to16_sch=0 by hhid: replace all5to16_sch=1 if inrange(age, 5,16) & years_edu !=0
Comment