I want to tag father and son in every household. The dataset has HHID (household unique identifier), PID (each person unique identifier), gender, marital status, and relation to head (which comes in 9 codes). I am sharing a sample f my dataset. Kindly help me in this regard
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str9 HHID str11 PID byte HH_Size str1 Relation_to_Head byte(gender Marital_Status) "410001101" "41000110101" 1 "1" 2 1 "410001102" "41000110201" 3 "1" 1 2 "410001102" "41000110202" 3 "2" 2 2 "410001102" "41000110203" 3 "5" 2 1 "410001103" "41000110301" 6 "1" 1 2 "410001103" "41000110302" 6 "2" 2 2 "410001103" "41000110303" 6 "3" 1 2 "410001103" "41000110304" 6 "4" 2 2 "410001103" "41000110305" 6 "6" 1 1 "410001103" "41000110306" 6 "6" 2 1 "410001201" "41000120101" 3 "1" 1 2 "410001201" "41000120102" 3 "2" 2 2 "410001201" "41000120103" 3 "5" 1 1 "410001202" "41000120201" 4 "1" 1 2 "410001202" "41000120202" 4 "2" 2 2 "410001202" "41000120203" 4 "5" 2 1 "410001202" "41000120204" 4 "5" 2 1 "410001203" "41000120301" 4 "1" 1 2 "410001203" "41000120302" 4 "2" 2 2 "410001203" "41000120303" 4 "5" 1 1 "410001203" "41000120304" 4 "5" 2 1 "410001204" "41000120401" 4 "1" 1 2 "410001204" "41000120402" 4 "2" 2 2 "410001204" "41000120403" 4 "5" 1 1 "410001204" "41000120404" 4 "5" 1 1 "410001301" "41000130101" 4 "1" 2 3 "410001301" "41000130102" 4 "5" 2 1 "410001301" "41000130103" 4 "5" 2 1 "410001301" "41000130104" 4 "5" 2 1 "410011101" "41001110101" 3 "1" 1 2 "410011101" "41001110102" 3 "2" 2 2 "410011101" "41001110103" 3 "5" 1 1 "410011102" "41001110201" 4 "1" 1 2 "410011102" "41001110202" 4 "2" 2 2 "410011102" "41001110203" 4 "5" 1 1 "410011102" "41001110204" 4 "5" 2 1 "410011201" "41001120101" 4 "1" 1 2 "410011201" "41001120102" 4 "2" 2 2 "410011201" "41001120103" 4 "5" 1 1 "410011201" "41001120104" 4 "5" 2 1 "410011202" "41001120201" 6 "1" 1 2 "410011202" "41001120202" 6 "2" 2 2 "410011202" "41001120203" 6 "5" 1 1 "410011202" "41001120204" 6 "5" 1 1 "410011202" "41001120205" 6 "5" 1 1 "410011202" "41001120206" 6 "5" 2 1 "410011203" "41001120301" 5 "1" 1 2 "410011203" "41001120302" 5 "2" 2 2 "410011203" "41001120303" 5 "5" 1 1 "410011203" "41001120304" 5 "5" 1 1 "410011203" "41001120305" 5 "5" 2 1 "410011204" "41001120401" 4 "1" 1 2 "410011204" "41001120402" 4 "2" 2 2 "410011204" "41001120403" 4 "5" 1 1 "410011204" "41001120404" 4 "5" 2 1 "410011301" "41001130101" 5 "1" 1 2 "410011301" "41001130102" 5 "2" 2 2 "410011301" "41001130103" 5 "5" 1 1 "410011301" "41001130104" 5 "5" 2 1 "410011301" "41001130105" 5 "5" 2 1 "410011302" "41001130201" 3 "1" 1 2 "410011302" "41001130202" 3 "2" 2 2 "410011302" "41001130203" 3 "5" 2 1 "410021101" "41002110101" 5 "1" 2 3 "410021101" "41002110102" 5 "3" 1 2 "410021101" "41002110103" 5 "4" 2 2 "410021101" "41002110104" 5 "6" 2 1 "410021101" "41002110105" 5 "6" 2 1 "410021102" "41002110201" 2 "1" 1 4 "410021102" "41002110202" 2 "7" 2 3 "410021103" "41002110301" 5 "1" 1 2 "410021103" "41002110302" 5 "2" 2 2 "410021103" "41002110303" 5 "5" 1 1 "410021103" "41002110304" 5 "5" 1 1 "410021103" "41002110305" 5 "5" 2 1 "410021104" "41002110401" 3 "1" 1 2 "410021104" "41002110402" 3 "2" 2 2 "410021104" "41002110403" 3 "5" 1 1 "410021201" "41002120101" 5 "1" 1 2 "410021201" "41002120102" 5 "2" 2 2 "410021201" "41002120103" 5 "5" 1 1 "410021201" "41002120104" 5 "5" 2 1 "410021201" "41002120105" 5 "5" 2 1 "410021202" "41002120201" 4 "1" 1 2 "410021202" "41002120202" 4 "2" 2 2 "410021202" "41002120203" 4 "5" 2 1 "410021202" "41002120204" 4 "5" 2 1 "410021203" "41002120301" 5 "1" 1 2 "410021203" "41002120302" 5 "2" 2 2 "410021203" "41002120303" 5 "5" 1 1 "410021203" "41002120304" 5 "5" 1 1 "410021203" "41002120305" 5 "5" 2 1 "410021204" "41002120401" 4 "1" 1 2 "410021204" "41002120402" 4 "2" 2 2 "410021204" "41002120403" 4 "5" 1 1 "410021204" "41002120404" 4 "5" 2 1 "410031101" "41003110101" 4 "1" 1 2 "410031101" "41003110102" 4 "2" 2 2 "410031101" "41003110103" 4 "5" 1 1 "410031101" "41003110104" 4 "5" 1 1 end label values gender sex1 label def sex1 1 "Male", modify label def sex1 2 "Female", modify label values Marital_Status marry label def marry 1 "never married", modify label def marry 2 "currently married", modify label def marry 3 "widowed", modify label def marry 4 "Divorced/separated", modify
self -1, spouse of head -2, married child -3, spouse of married child -4, unmarried child -5, grandchild -6, father/ mother/ father-in-law/ mother-in-law -7, brother/ sister/ brother-in-law/ sister-in-law/ other relatives -8, servants/ employees/ other non-relatives -9. I am here interested in finding out only two generation; father and his son, who may be married or unmarried or divorced/separated or widower. Thanks. |
0 Response to How to tag Father and Son in a dataset using Household identifier
Post a Comment