Nuclear households are households comprised of a married couple or a man or a woman living alone or with unmarried children (biological, adopted, or fostered) with or without unrelated individuals. hv101 codes: 1 head 2 wife or husband 3 son/daughter 4 son/daughter-in-law 5 grandchild 6 parent 7 parent-in-law 8 brother/sister 10 other relative 11 adopted/foster/stepchild 12 not related 15 brother-in-law/sister-in-law 16 niece/nephew 17 domestic servent 98 don't know open a PR file */ keep hv000-hv002 hv101 hv104 hv105 sh08 * construct binary (0/1) codes for each type of person gen ft_1=0 gen ft_1_m=0 gen ft_1_f=0 gen ft_2=0 gen ft_2_m=0 gen ft_2_f=0 gen ft_3=0 gen ft_3_um=0 gen ft_4=0 gen ft_5=0 gen ft_6=0 gen ft_6_m=0 gen ft_6_f=0 gen ft_7=0 gen ft_8=0 gen ft_10=0 gen ft_11=0 gen ft_12=0 gen ft_15=0 gen ft_16=0 gen ft_17=0 replace ft_1=1 if hv101==1 replace ft_1_m=1 if hv101==1 & hv104==1 replace ft_1_f=1 if hv101==1 & hv104==2 replace ft_2=1 if hv101==2 replace ft_2_m=1 if hv101==2 & hv104==1 replace ft_2_f=1 if hv101==2 & hv104==2 replace ft_3=1 if hv101==3 replace ft_3_um=1 if hv101==3 & sh08==1 replace ft_4=1 if hv101==4 replace ft_5=1 if hv101==5 replace ft_6=1 if hv101==6 replace ft_6_m=1 if hv101==6 & hv104==1 replace ft_6_f=1 if hv101==6 & hv104==2 replace ft_7=1 if hv101==7 replace ft_8=1 if hv101==8 replace ft_10=1 if hv101==10 replace ft_11=1 if hv101==11 replace ft_12=1 if hv101==12 replace ft_15=1 if hv101==15 replace ft_16=1 if hv101==16 replace ft_17=1 if hv101==17 collapse (sum) ft_*, by(hv001 hv002) * in the collapsed file, these variables will give the number of people within each household who are of each type * now construct household types based on combinations of the presence or absence of each type of person * in the following example I do not take account of the age of the person, which could be important! gen ft=. gen relatives=ft_5+ft_6+ft_8+ft_10+ft_16 replace ft=1 if ft_1>=1 | ft_2>=1 | (ft_1>=1 & ft_2>=1) & ft_3_um>=0 & ft_11>=0 & ft_12>=0 & ft_17>=0 replace ft=2 if (ft_1>=1 & ft_2>=1) & ft_3>=0 & relatives>=1 | ft_4>=1 | ft_7>=1 | ft_11>=1 | ft_12>=1 | ft_15>=1 | ft_17>=1 drop ft_* relatives label define ft 1 "Nuclear" 2 "Non-nuclear" label values ft ft label variable ft "Family type" tab ft, m