Dear all,
How do I generate household head age, education level and other household size. My data doesn't have a PID though it has hhid and uniqkey and respondent characteristics (questionnaire).
Am using Stata/IC 14.1
******Head Age
egen age_hh = total(age_resp* (age_resp >=16)), by(pid)
replace age_hh = age_hh - age_resp * (age_resp >= 18)
I tried this for age of household head which seems to have worked though when I sum age_hh I get mean age_hh of approximately 80 years old.
How do I generate household head age, education level and other household size. My data doesn't have a PID though it has hhid and uniqkey and respondent characteristics (questionnaire).
Am using Stata/IC 14.1
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(uniqkey hhid gender_resp age_resp relation_head edu_resp) 23592911 11 1 18 3 4 23456297 50 2 35 2 2 24080977 25 2 30 2 1 23026061 50 1 18 3 4 24080972 12 2 49 1 1 23996364 93 2 33 1 1 23466688 37 1 29 4 2 23526939 19 1 46 1 2 22952404 22 1 45 1 5 23716844 15 2 22 2 4 23332897 41 2 19 2 2 23331005 4 1 24 5 7 22437981 94 1 23 1 5 23963878 33 2 36 1 7 23686337 8 2 24 2 3 22656751 67 2 21 2 7 24121285 65 2 70 2 4 23100222 52 2 37 2 5 23182298 81 2 23 2 4 23248881 11 1 23 1 5 23028824 28 1 35 1 5 end label values gender_resp gender_resp label def gender_resp 1 "Male", modify label def gender_resp 2 "Female", modify label values relation_head relation_head label def relation_head 1 "Head", modify label def relation_head 2 "Spouse", modify label def relation_head 3"Son/Daughter", modify label def relation_head 4 "Father/Mother", modify label def relation_head 5 "Sister/Brother", modify label values edu_resp edu_resp label def edu_resp 1 "None", modify label def edu_resp 2 "Some primary ", modify label def edu_resp 3 "Primary completed", modify label def edu_resp 4 "Some secondary ", modify label def edu_resp 5 "Secondary completed", modify label def edu_resp 7 "University degree", modify
egen age_hh = total(age_resp* (age_resp >=16)), by(pid)
replace age_hh = age_hh - age_resp * (age_resp >= 18)
I tried this for age of household head which seems to have worked though when I sum age_hh I get mean age_hh of approximately 80 years old.
Comment