***************************** *Preamble ***************************** set more off clear *Define the working directory cd "E:\Wave_1" /*Define the data source directory, where there should contain file A_INDRESP A_HHRESP A_EGOALT A_MARRIAGE A_NATCHILD A_INDALL */ global datadir "E:\Original Data\UKDA-6614-stata11_se\stata11_se" ******************************************************************************** * Preparation:Basic Structure Construction ******************************************************************************** use "$datadir\a_indresp.dta" //The whole data file will be based on UNDERSTANDING SOCIETY A_INDRESP file save File_UK, replace capture mkdir ukcompute *Merge useful variables from family file UNDERSTANDING SOCIETY A_HHRESP merge m:1 a_hidp using "$datadir\a_hhresp.dta" drop if _merge == 2 drop _merge save File_UK, replace *Relationship variables from A_EGOALT use "$datadir\a_egoalt" keep if a_apno == 1 keep a_pno pidp apidp a_relationship_dv //apidp: target individual rename pidp relationp rename apidp pidp reshape wide relationp a_relationship_dv , i(pidp) j(a_pno) *a_relationship_dv* : what 'Person relationp*' is to 'Person pidp' save ukcompute\relation, replace use File_UK merge m:1 pidp using ukcompute\relation drop if _merge == 2 drop _merge save File_UK, replace ***************************** *Part0. IDs and weights ***************************** * Year of Survey *a_istrtdaty from a_indresp gen a_syear = a_istrtdaty label variable a_syear "Year of Survey" tab a_syear, mi * Month of Survey *a_istrtdatm from a_indresp gen a_smonth = a_istrtdatm label variable a_smonth "Month of Survey" tab a_smonth, mi * Individual id *a_pid clonevar a_pid = pidp label var a_pid "Individual Number" * Family id *a_hidp household identifier(public release) gen a_fid = a_hidp label var a_fid "Family ID" insp a_fid * Cross wave person identifier (for pannel data) *pidp gen a_pidp = pidp label var a_pidp "Cross Wave Person Identifier" insp a_pidp * Individual sample weight *a_indpxus_xw: Cross-sectional adult main interview weight gen a_pweight = a_indpxus_xw label var a_pweight " Individual Sample Weight" insp a_pweight * Family sample weight a_fweight *a_hhdenus_xw cross-sectional household weight clonevar a_fweight = a_hhdenus_xw label var a_fweight "Family Sample Weight" insp a_fweight ***************************** *Part1. Basic Demographic ***************************** * R's year of birth *a_birthy from a_indresp label var a_birthy "R's Year of Birth" * R's age *a_age_cr from a_indresp gen a_age = a_age_cr label var a_age "R's age" insp a_age * R's gender *a_sex_cr from a_indresp gen a_gender = a_sex_cr label var a_gender "R's gender" label define a_sex_l 1 "Male" 2"Female" label value a_gender a_sex_l tab a_gender,mi * R's ethnicity *a_racel from a_indresp clonevar a_ethnica = a_racel replace a_ethnica = . if a_racel == -9 replace a_ethnica = -8 if a_racel == -8 | a_racel == -7 replace a_ethnica = -2 if a_racel == -2 replace a_ethnica = -1 if a_racel == -1 label val a_ethnica a_racel label var a_ethnica "R's Ethnicity" tab a_ethnica, mi gen a_ethnicb = . replace a_ethnicb = 1 if a_racel == 1 //majority replace a_ethnicb = 2 if a_racel >= 2 //minority replace a_ethnicb = -8 if a_racel == -8 | a_racel == -7 replace a_ethnicb = . if a_racel == -9 replace a_ethnicb = -2 if a_racel == -2 replace a_ethnicb = -1 if a_racel == -1 label var a_ethnicb "R's Ethnicity: Majority or not" label define a_ethnicb_l 1 "Majority: British" 2 "Minority" -8"Not Applicable" -2 "Refused to Answer" -1"Don't Know" label value a_ethnicb a_ethnicb_l tab a_ethnicb, mi * R's place of residence is urban or rural a_urban *a_urban_dv from a_indresp clonevar a_urban = a_urban_dv label var a_urban "R's place of residence" tab a_urban, mi * Number of siblings of R a_sib *a_nrelsw12 number of absent brothers or sisters *a_relationship_dv* (2-16) find gen a_sib = 0 forvalues i=2/16{ replace a_sib = a_sib + 1 if a_relationship_dv`i' == 14 | a_relationship_dv`i' == 15 *not including step/adopted siblings } replace a_sib = a_sib + a_nrelsw12 if a_nrelsw12 >=0 replace a_sib = a_nrelsw12 if a_sib == 0 & a_nrelsw12 != -8 recode a_sib (-9 = .) (-7=-8) label define numeric_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" label define yesno -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" 0 "No" 1"Yes" label value a_sib numeric_l label var a_sib "Number of Siblings of R" tab a_sib,mi tab a_sib if a_sib>=0 * Number of children of R a_child *a_lprnt ever had children *a_lnprnt number of biolofical children ever had gen a_child = a_lnprnt replace a_child = 0 if a_lprnt == 2 //have no kid recode a_child (-9=.) label value a_child numeric_l label var a_child "Number of Children of R" tab a_child,mi tab a_child if a_child >=0 save File_UK, replace * See Part 10 for variables about father, mother, spouse and children ***************************** *Part 2. Education ***************************** * Years of Schooling of R *a_scend from a_indresp: school leaving age gen a_eduy = a_scend replace a_eduy = a_scend-5 if a_scend >0 mvdecode a_eduy, mv(-9) label define a_eduy_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" 15"Over 15 years" label value a_eduy a_eduy_l label var a_eduy "Years of Schooling of R" tab a_eduy, mi tab a_eduy if a_eduy > 0 * Highest educational level attained by R *a_qfhigh from a_indresp gen a_edu = . replace a_edu = -8 if a_qfhigh == -8 | a_qfhigh == 15 // "Not Applicable" replace a_edu = -2 if a_qfhigh == -2 // "Refuse to Answer" replace a_edu = -1 if a_qfhigh == -1 // Don't Know replace a_edu = 1 if a_qfhigh == 96 // 1. Elementary and Below replace a_edu = 2 if a_qfhigh == 12 | a_qfhigh == 13 | a_qfhigh == 14 * 2. Junior High and Vocational School replace a_edu = 3 if a_qfhigh == 6 | a_qfhigh == 7 | a_qfhigh == 8 | a_qfhigh == 9|a_qfhigh == 10|a_qfhigh == 11 * 3. Senior High and Vocational School replace a_edu = 4 if a_qfhigh == 4|a_qfhigh == 5 // 4. Vocational College or Some College replace a_edu = 5 if a_qfhigh == 1 | a_qfhigh == 2|a_qfhigh == 3 // 5. Bachelor Degree and above label define a_edu_l 1 "Elementary and Below" 2 "Junior High and Vocational School" 3 "Senior High and Vocational School" 4 "Vocational College or Some College" 5 "Bachelor Degree and Above" -1 "Don't Know" -2 "Refuse to Answer" -8 "Not Applicable" label values a_edu a_edu_l label variable a_edu "Highest Educational Level Attained" tab a_edu, mi tab a_edu if a_edu > 0 save File_UK, replace * See Part 10 for variables about father, mother, spouse and children ***************************** *Part 3. Individual's Labor Market Outcomes ***************************** * Employment Status *a_jbstat drop a_employ gen a_employ= . replace a_employ = 1 if a_jbstat == 1 | a_jbstat == 2 | a_jbstat == 5 | a_jbstat == 10 *1. Employed: including 5 on maternity leave & 10 unpaid worker in family business replace a_employ = 2 if a_jbstat ==3 //2. Unemployed replace a_employ = 3 if a_jbstat ==4 | a_jbstat >=6 & a_jbstat <= 9 //3. Not in Labour Market replace a_employ = -1 if a_jbstat == 97 replace a_employ = -2 if a_jbstat == -2 //-2. Refused replace a_employ = -1 if a_jbstat == -1 //-1. DK recode a_employ (97 = -1) (-7=-8) (-9=.) label define a_employ_l 1 "Employed" /// 2 "Unemployed" /// 3 "Not in Labour Market" /// -8 "Not Applicable" -2 "Refused" -1 "Don't Know" label values a_employ a_employ_l label variable a_employ "Employment Status" tab a_employ , mi tab a_employ if a_employ >=0 * Working hours per week a_workhour_week *a_jbhrs clonevar a_workhour_week = a_jbhrs replace a_workhour_week = . if a_jbhrs == -9 label define a_workhour_l -8 "Not Applicable" /// -2 "Refused" /// -1 "Don't Know" label values a_workhour_week a_workhour_l label variable a_workhour_week "Working Hours per Week" sum a_workhour_week if a_workhour_week>0 tab a_workhour_week if a_workhour_week<=0 * Occupation (ISCO88/08 standardization) a_isco *a_jbisco88_cc clonevar a_isco = a_jbisco88_cc mvdecode a_isco, mv(-9) replace a_isco =-8 if a_jbisco88_cc == -7 label var a_isco "Occupation (ISCO88/08 standardization)" *make frequency table by 100 label define isco1 -8 "Not Applicable" -2 "Refuse to Answer"-1 "Don't Know" /// 1"Legislators, Senior Officials And Managers" /// 2"Professionals" /// 3"Technicians And Associate Professionals" /// 4"Clerks" /// 5"Service Workers And Shop And Market Sales Workers" /// 6"Skilled Agricultural And Fishery Workers" /// 7"Craft And Related Trades Workers" /// 8"Plant And Machine Operators And Assemblers" /// 9"Elementary Occupations" /// 0"Armed Forces" clonevar a_isco1 = a_isco replace a_isco1 = int(a_isco1/100) if a_isco1 > 0 label values a_isco1 isco1 tab a_isco1,mi tab a_isco1 if a_isco1 >= 0 * Occupation of R's first job a_isco_first *a_j1soc10_cc first job: SOC 2010, condensed 3-digit version clonevar a_isco_first = a_j1soc10_cc label var a_isco_first "Occupation of R's First Job" tab a_isco_first if a_isco_first <0 sum a_isco_first if a_isco_first>0 * Average monthly income (main job) *a_paynu_dv: usual net pay per month: current job clonevar a_monthinc=a_paynu_dv recode a_monthinc (-7=-8) label value a_monthinc numeric_l label var a_monthinc "Average monthly income (main job)" tab a_monthinc if a_monthinc <0 * Hourly wage rate clonevar a_hourwage= a_basrate recode a_hourwage (-7=-8) label value a_hourwage numeric_l label var a_hourwage "Hourly Wage Rate" tab a_hourwage sum a_hourwage if a_hourwage > 0 insp a_hourwage * Income from main job last year generate a_yearinc1=a_monthinc*12 replace a_yearinc1 = a_monthinc if a_monthinc < 0 label value a_yearinc1 numeric_l label var a_yearinc1 "Income from main job last year" tab a_yearinc1 sum a_yearinc1 if a_yearinc1 > 0 insp a_yearinc1 * Month net income from second job *a_inc1clabj2: amount income component 1c: net earnings second job clonevar a_monthwage_second=a_inc1clabj2 if a_j2has==1 * Income from other job last year generate a_yearinc2=a_monthwage_second*12 replace a_yearinc2=a_inc1clabj2 if a_inc1clabj2 < 0 replace a_yearinc2 = a_j2has if mi(a_yearinc2) & a_j2has < 0 & !mi(a_j2has) replace a_yearinc2 = -8 if a_j2has == 2 recode a_yearinc2 (-7=-8) (-9=.) label value a_yearinc2 numeric_l label var a_yearinc2 "Income from other job last year" * Annual pension clonevar a_pensioninc=a_inc6pen replace a_pensioninc=a_pensioninc*12 replace a_pensioninc = a_inc6pen if a_inc6pen <0 recode a_pensioninc (-7=-8) label value a_pensioninc numeric_l label var a_pensioninc "Annual Pension" * Annual labor income egen a_income=rowtotal(a_yearinc1 a_yearinc2),missing replace a_income = a_yearinc1 if mi(a_yearinc2) | a_yearinc2 < 0 replace a_income = a_yearinc2 if mi(a_yearinc1) | a_yearinc1 < 0 replace a_income = -8 if a_yearinc1 == -8 & a_yearinc2 == -8 label value a_income numeric_l label var a_income "Annual Labor Income" * Tenure of current job a_tenure *a_jbbgy year started current job *a_syear year of survey gen a_tenure = a_syear - a_jbbgy replace a_tenure = . if a_jbbgy == -9 replace a_tenure = -8 if a_jbbgy == -8 replace a_tenure = -2 if a_jbbgy == -2 replace a_tenure = -1 if a_jbbgy == -1 label define a_tenure_l -8 "Not Applicable" /// -2 "Refused" /// -1 "Don't Know" /// 0 "Below 1 Year" label value a_tenure a_tenure_l label var a_tenure "Tenure of current job" tab a_tenure, mi sum a_tenure if a_tenure>0 * Job satisfaction *a_jbsat gen a_jobsat=. replace a_jobsat = 1 if a_jbsat == 1 replace a_jobsat = 2 if a_jbsat == 2 | a_jbsat == 3 replace a_jobsat = 3 if a_jbsat == 4 replace a_jobsat = 4 if a_jbsat == 5 | a_jbsat == 6 replace a_jobsat = 5 if a_jbsat == 7 replace a_jobsat = -8 if a_jbsat == -8 | a_jbsat == -7 replace a_jobsat = -2 if a_jbsat == -2 replace a_jobsat = -1 if a_jbsat == -1 label define a_jobsat_l -8 "Not Applicable" -2 "Refused" /// -1 "Don't Know" 1 "Very Unsatisfied" 2 "Unsatisfied" /// 3 "Fair" 4 "Satisfied" 5 "Very Satisfied" label values a_jobsat a_jobsat_l label variable a_jobsat "Job Satisfaction" tab a_jobsat,mi tab a_jobsat if a_jobsat >=0 * Whether has injury insurance a_injureinsur *a_btype3 sick, disab or incapacity benifits gen a_injureinsur = a_btype3 replace a_injureinsur = -8 if a_btype3 == -7 replace a_injureinsur = . if a_btype3 == -9 label define a_inj_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label value a_injureinsur a_inj_l label var a_injureinsur "Whether has injury insurance" tab a_injureinsur,mi * Whether has unemployment insurance a_unemployinsur *a_btype1 unemployment-related benefits, or national insurance credits? gen a_unemployinsur = a_btype1 replace a_unemployinsur = -8 if a_btype1 == -7 replace a_unemployinsur = . if a_btype1 == -9 label define a_une_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label value a_unemployinsur a_une_l label var a_unemployinsur "Whether has unemployment insurance" tab a_unemployinsur, mi * Whether has pension a_pension *a_btype4 any pension inc. a private pension or state pension? gen a_pension = a_btype4 replace a_pension = -8 if a_btype4 == -7 replace a_pension = . if a_btype4 == -9 label define a_pen_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label value a_pension a_pen_l label var a_pension "Whether has pension" tab a_pension, mi * Whether has maternity insurance or whether it's included by R's health insurance a_materinsur *a_benfam2 : maternity allowance gen a_materinsur = a_benfam2 replace a_materinsur = -8 if a_benfam2 ==-7 label define a_mater_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label value a_materinsur a_mater_l label var a_materinsur "Are receiving any maternity allowance" tab a_materinsur, mi save File_UK, replace ***************************** *Part. 4 Household Economic Activities ***************************** ******************************************************************************** * a_fsize * a_hhsize * a_gen * a_fstru * a_hhstruc ******************************************************************************** * a_gen use "$datadir\a_egoalt",clear count if a_relationship[_n]!=a_relationship_dv[_n] //1637// keep if a_pno==1 save ukcompute\fstru_UK,replace recode a_relationship_dv (1/3=1) (4/7=2)(8=3) (9/12=4)(13=5) (14/19=6) (20=7) (21=8) /// (22=9) (23=10) (24=11) (25=12) (26/30=13) (-1=100)(-9=100), generate (relationshiptag) /* relationshiptag 1: partners 2: children 3: children-in-law 4: parents 5: parents-in-law 6:siblings 7:grandchildren 8: grandparents 9: cousin 10: aunt/uncle 11: niece/nephew 12: other relatives 13: other non-relatives 100: know not know*/ recode relationshiptag (1=0) (2=-1)(3=-1)(4/5=1)(6=0)(7=-2)(8=2)(9=0)(10=1)(11=-1)(12/13=0), gen(gen) *0: same gen -2 grandchild gen -1:child gen 1:parent gen 2:granparent gen egen gentag=max(gen),by(a_hidp) generate gentab=1 if gentag <100 replace gentab=3 if gentag==100 gen a_gen=. egen genm=max(gen) if gentab==1, by(a_hidp) egen genn=min(gen) if gentab==1, by(a_hidp) replace a_gen=genm-genn+1 if genm > 0 & genn < 0 replace a_gen=genm+1 if genm > 0 & genn > 0 replace a_gen=genm+1 if genm > 0 & genn== 0 replace a_gen=-genn+1 if genm < 0 & genn < 0 replace a_gen=-genn+1 if genm== 0 & genn < 0 replace a_gen=1 if genm== 0 & genn== 0 *summary: gen a_gen = max(0,genm)-min(0,genn)+1 replace a_gen = -8 if a_gen == . replace a_gen=4 if a_gen>4&a_gen!=. label variable a_gen "Number of generations in household" label define a_gen -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" 1 "1 Generation" 2 "2 Generations" 3 "3 Generations" 4 "4 or more Generations" label val a_gen a_gen bysort a_hidp: gen tag=_n keep a_hidp tag a_gen a_relationship_dv relationshiptag reshape wide a_relationship_dv a_gen relationshiptag,i(a_hidp) j(tag) clonevar gen = a_gen1 drop a_gen* rename gen a_gen label variable a_gen "Number of generations in household" save ukcompute\fstru_UK,replace * a_fsize:householdsize-(employee+emloyer+Lodger/Boarder/Tenan+Landlord/Landlady+Other non-relative) use "$datadir\a_hhresp",clear merge 1:1 a_hidp using ukcompute\fstru_UK drop _merge generate a_fsize=a_hhsize forvalue i=26/30{ forvalue j=1/15{ qui replace a_fsize=a_fsize-1 if a_relationship_dv`j'==`i' } } * Family Structure a_fstru *coresid. forvalues i=1/13 { generate coresid`i'=0 { forvalues j=1/15{ qui replace coresid`i'=1 if relationshiptag`j'==`i' } } } *** attention: relationshiptag refers to relationship to alters*** /* family structure: 1:primary individual family, 2:single parent family, *** 3:couple with no children, 4:couple with children, *********************** 5: stem family (parent with married children, with or without grandchilren), 6:other**/ generate a_fstruc=6 *Primary-individual family replace a_fstruc=1 if a_hhsize==1 | a_fsize == 1 replace a_fstruc=1 if a_hhtype==1|a_hhtype==2|a_hhtype==3 *Single-parent family, single with children, no extended, no non relatives *how many parent in family gen n_parent=0 forvalues j=1/15{ qui replace n_parent=n_parent+1 if a_relationship_dv`j'==4|a_relationship_dv`j'==5|a_relationship_dv`j'==7 } replace a_fstruc=2 if coresid1==0 &coresid2==0&coresid3==0& coresid4==1 & /// coresid5==0 & coresid6==0&coresid7==0&coresid8==0&coresid9==0&coresid10==0& /// coresid11==0&coresid12==0 //ego:parent, alter:child replace a_fstruc=2 if n_parent==1 & coresid1==0 &coresid2== 1 &coresid3==0 &coresid4==0 & /// coresid5==0 & coresid6== 1 &coresid7==0&coresid8==0&coresid9==0&coresid10==0& /// coresid11==0&coresid12==0 //ego:child, alter:parent, sibling replace a_fstruc=2 if n_parent==1&coresid1==0 & coresid2==1&coresid3==0 &coresid4==0 & /// coresid5==0 & coresid6==0&coresid7==0&coresid8==0&coresid9==0&coresid10==0& /// coresid11==0&coresid12==0 //ego:child, alter:parent *Couple with no children (two person family) replace a_fstruc=3 if coresid1==1&coresid2==0&coresid3==0&coresid4==0 & /// coresid5==0&coresid6==0&coresid7==0&coresid8==0&coresid9==0&coresid10==0& /// coresid11==0&coresid12==0 //ego+spouse/partner *Couple with unmarried children *ego+partner/spouse+child replace a_fstruc=4 if coresid1==1&coresid2==0&coresid3==0&coresid4==1& coresid5==0& coresid6==0& coresid7==0& coresid8==0&coresid9==0&coresid10==0 &coresid11==0& coresid12==0 *ego+both parents replace a_fstruc=4 if n_parent==2&coresid1==0 &coresid2==1&coresid3==0 &coresid4==0& coresid5==0 & coresid6==0&coresid7==0&coresid8==0&coresid9==0&coresid10==0& coresid11==0&coresid12==0 *ego+both_parents+siblings replace a_fstruc=4 if n_parent==2&coresid1==0 &coresid2==1&coresid3==0 &coresid4==0& coresid5==0 & coresid6==1&coresid7==0&coresid8==0&coresid9==0&coresid10==0& coresid11==0&coresid12==0 *Stem family (parents with married children, with or without grandchildren, including grandparent+grandchildren family) *child+child in law+ego+ego's parent/parent in law replace a_fstruc=5 if (coresid4==1 & coresid5==1)& (coresid2==1|coresid3==1) & coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *child+child in law+ego replace a_fstruc=5 if (coresid4==1 & coresid5==1) & (coresid2==0 &coresid3==0)& coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *child in law+ego+ego's parent/parent in law replace a_fstruc=5 if (coresid4==0 & coresid5==1)&(coresid2==1|coresid3==1)&coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *child in law+ego replace a_fstruc=5 if (coresid4==0 & coresid5==1)&(coresid2==0&coresid3==0)&coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *child+ego+ego's parent/parent in law replace a_fstruc=5 if (coresid4==1 & coresid5==0)&(coresid2==1|coresid3==1)&coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *child+ego+ego's grandparent/grandchild replace a_fstruc=5 if (coresid4==1 & coresid5==0)& (coresid7==1|coresid8==1)&coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *ego+ego's grandparent/grandchild replace a_fstruc=5 if (coresid4==0 & coresid5==0)& (coresid7==1|coresid8==1)&coresid6==0&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 *ego+ego's grandparent+ego's sibling replace a_fstruc=5 if (coresid4==0 & coresid5==0)& coresid7==1&coresid8==0&coresid6==1&coresid9==0 &coresid10==0 & coresid11==0 & coresid12==0 forvalues i = 1/15 { replace a_fstruc = -8 if relationshiptag`i' == 100 } label define fstruc_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "Primary Individual Family" 2 "Single-Parent Family" 3 "Married Couple with No Children" /// 4 "Married Couple with Children" 5 "Stem" 6"Other Family" label value a_fstruc fstruc_l label var a_fstruc "Family Structure" replace a_gen = 1 if mi(a_gen) & a_fstruc == 1 label variable a_gen "Number of generations in household" label define numeric_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" label value a_fsize numeric_l label var a_fsize "Family Size" * Household structurea_hhstruc ***attention: household structure here considers non-relatives in one household, not only members in one family unit gen a_hhstruc=a_fstruc replace a_hhstruc=7 if coresid13==1 label define hhstruc -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "Primary Individual Household" 2 "Single-Parent Household" 3 "Married Couple with No Children" /// 4 "Married Couple with Children" 5 "Stem Family Household" 6"Other Household with No Non-relatives" 7 "Other Household With Non-relatives" label value a_hhstruc hhstruc label var a_hhstruc "Household Structure" keep a_hidp a_gen a_fsize a_hhsize a_fstruc a_hhstruc save ukcompute\fstru_UK,replace use File_UK merge m:1 a_hidp using ukcompute\fstru_UK drop if _merge == 2 drop _merge * Family net income after government adjustment gen a_fminc=a_hhnetinc1 label var a_fminc "Monthly total family net income- no deduction of civil tax" gen a_faminc=12*a_fminc label var a_faminc "Post-government total family net income" rename a_faminc a_faminc_post sum a_faminc_post save File_UK, replace * Family income before government adjustment *use social benefit income variable in the individual data set to obtain the household public transfer income keep a_hidp a_inc7sben by a_hidp,sort:gen n=_n reshape wide a_inc7sben, i(a_hidp) j(n) forvalues i=1(1)9 { replace a_inc7sben`i'=0 if a_inc7sben`i'==. } gen a_welfare=a_inc7sben1+a_inc7sben2+a_inc7sben3+a_inc7sben4+a_inc7sben5+a_inc7sben6+a_inc7sben7+a_inc7sben8+a_inc7sben9 label var a_welfare "Household welfare income" keep a_hidp a_welfare save ukcompute\welfare, replace use File_UK merge m:1 a_hidp using ukcompute\welfare drop _merge replace a_welfare=0 if a_welfare==. gen a_faminc_pre=(a_fihhmngrs_dv-a_welfare)*12 label var a_faminc_pre "Pre-government Yearly household income" save File_UK, replace ***************************** *Part. 5 Marriage ***************************** * Current marital status a_marriage *a_marstat legal marital status gen a_marriage = . replace a_marriage = -8 if a_marstat == -8 replace a_marriage = -2 if a_marstat == -2 replace a_marriage = -1 if a_marstat == -1 replace a_marriage = 1 if a_marstat == 2 | a_marstat == 3 //married/in a civil partnership replace a_marriage = 2 if a_marstat == 1 //Single replace a_marriage = 3 if a_marstat == 6 | a_marstat == 9 //Widowed/ Partner died replace a_marriage = 4 if a_marstat == 5 | a_marstat == 8 //Divorced, civil partnership legally dissolved replace a_marriage = 1 if a_marstat == 4 | a_marstat == 7 //Separated --> married label define mar_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 1 "Married" 2"Single" 3"Widowed" /// 4 "Divorced, annulment" label value a_marriage mar_l label var a_marriage "Current Marital Status" tab a_marriage, mi * Year of current marriage a_cmarri_y *a_lcmary gen a_cmarri_y = a_lcmary recode a_cmarri_y (-9=.)(-7=-8) label var a_cmarri_y "Year of Current Marriage" label define cmarriy_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" label value a_cmarri_y cmarriy_l tab a_cmarri_y,mi * Month of current marriage a_cmarri_m *a_lcmarm gen a_cmarri_m = a_lcmarm recode a_cmarri_m (-9=.)(-7=-8) label var a_cmarri_m "Month of Current Marriage" label define cmarriy_m -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" label value a_cmarri_m cmarriy_m tab a_cmarri_m,mi * Whether cohabited before current marriage a_cmarri_cohab *a_lcmcoh cohabited before current marriage gen a_cmarri_cohab = a_lcmcoh recode a_cmarri_cohab (-9=.)(-7=-8)(2=0) label define cmarri_coh_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label var a_cmarri_cohab "Whether Cohabited before Current Marriage" label value a_cmarri_cohab cmarri_coh_l tab a_cmarri_cohab, mi * Duration of cohabitation before current marriage a_cmarri_cohabd *a_lcmcby4 year began cohabiting before current marriage gen a_cmarri_cohabd = a_lcmary - a_lcmcby4 replace a_cmarri_cohabd = -8 if a_lcmary < 0 | a_lcmcby4 < 0 label define cohabd_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"Below 1 Year" label var a_cmarri_cohabd "Duration of cohabitation before current marriage" label value a_cmarri_cohabd cohabd_l tab a_cmarri_cohabd, mi sum a_cmarri_cohabd if a_cmarri_cohabd>0 save File_UK, replace *process a_marriage.dta use "$datadir/a_marriage" /* a_lmarm month of marriage a_lmary4 year of marriage a_lmcoh cohabited before marriage a_lmcbm month started living together a_lmcby4 year started living together a_lmend how marriage/civil partnership ended a_lmwwm month widowed/partner died a_lmwwy4 year widowed/partner died a_lspwwd co-resident when spouse/partner died a_lmdvm month divorced/civil partnership dissolved a_lmdvy4 year divorced/civil partnership dissolved*/ rename a_l*4 a_l* reshape wide a_lmarm-a_lmspy, i(a_hidp a_pno) j(a_marno) save ukcompute/marriage, replace use File_UK merge m:1 a_hidp a_pno using ukcompute/marriage drop _merge save File_UK, replace * Year of first marriage a_fmarri_y *a_nmar number of marriages gen a_fmarri_y = a_lmary1 replace a_fmarri_y = a_cmarri_y if a_nmar == 1 & mi(a_fmarri_y) replace a_fmarri_y = -8 if a_marriage == 2 // never married replace a_fmarri_y = a_nmar if mi(a_fmarri_y) & a_nmar < 0 recode a_fmarri_y (-9=.)(-7=-8) label var a_fmarri_y "Year of First Marriage" label value a_fmarri_y numeric_l tab a_fmarri_y, mi sum a_fmarri_y if a_fmarri_y > 0 * Month of first marriage a_fmarri_m gen a_fmarri_m = a_lmarm1 replace a_fmarri_m = a_cmarri_m if a_nmar == 1 & mi(a_fmarri_m) replace a_fmarri_m = -8 if a_marriage == 2 // never married replace a_fmarri_m = a_nmar if mi(a_fmarri_m) & a_nmar < 0 recode a_fmarri_m (-9=.) (-7=-8) label var a_fmarri_m "Month of First Marriage" label value a_fmarri_m numeric_l tab a_fmarri_m, mi tab a_fmarri_m if a_fmarri_m > 0 * Whether cohabited before first marriage a_fmarri_cohab gen a_fmarri_cohab = a_lmcoh1 recode a_fmarri_cohab (-9=.)(-7=-8) (2=0) replace a_fmarri_cohab = a_cmarri_cohab if a_nmar == 1 & mi(a_fmarri_cohab) replace a_fmarri_cohab = -8 if a_marriage == 2 // never married replace a_fmarri_cohab = a_nmar if mi(a_fmarri_cohab) & a_nmar < 0 recode a_fmarri_cohab (-9=.)(-7=-8) label var a_fmarri_cohab "Whether Cohabited before First Marriage" label value a_fmarri_cohab yesno tab a_fmarri_cohab, mi tab a_fmarri_cohab if a_fmarri_cohab >= 0 * End year of first marriage a_fmarri_endy gen a_fmarri_endy = a_lmend1 replace a_fmarri_endy = a_lmdvy1 if a_lmend1 == 1 replace a_fmarri_endy = a_lmwwy1 if a_lmend1 == 2 recode a_fmarri_endy (-9=.) (97=-8) replace a_fmarri_endy = -8 if a_marriage == 2 //never married replace a_fmarri_endy = -8 if mi(a_fmarri_endy) & a_marriage == 1 & a_nmar == 1 //still in 1st marriage replace a_fmarri_endy = a_nmar if mi(a_fmarri_endy) & a_nmar < 0 recode a_fmarri_endy (-9=.) (-7 =-8) label value a_fmarri_endy numeric_l label var a_fmarri_endy "End Year of First Marriage" tab a_fmarri_endy, mi sum a_fmarri_endy if a_fmarri_endy >0 * End month of first marriage a_fmarri_endm gen a_fmarri_endm = a_lmend1 replace a_fmarri_endm = a_lmdvm1 if a_lmend1 == 1 replace a_fmarri_endm = a_lmwwm1 if a_lmend1 == 2 recode a_fmarri_endm (-9=.) (97=-8) replace a_fmarri_endm = -8 if a_marriage == 2 //never married replace a_fmarri_endm = -8 if mi(a_fmarri_endm) & a_marriage == 1 & a_nmar == 1 //still in 1st marriage replace a_fmarri_endm = a_nmar if mi(a_fmarri_endm) & a_nmar < 0 recode a_fmarri_endm (-9=.) (-7 =-8) label value a_fmarri_endm numeric_l label var a_fmarri_endm "End Month of First Marriage" tab a_fmarri_endm, mi tab a_fmarri_endm if a_fmarri_endm >0 * Reason for the end of first marriage a_fmarri_endreason gen a_fmarri_endreason = a_lmend1 recode a_fmarri_endreason (-9=.)(97=3) replace a_fmarri_endreason = -8 if a_marriage == 2 //never married replace a_fmarri_endreason = -8 if mi(a_fmarri_endreason) & a_marriage == 1 & a_nmar == 1 //still in 1st marriage replace a_fmarri_endreason = a_nmar if mi(a_fmarri_endreason) & a_nmar < 0 recode a_fmarri_endreason (-9=.) (-7 =-8) label var a_fmarri_endreason "Reason for the end of first marriage" label define endreason_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 1 "Divorced" 2"Widowed" 3"Others" label value a_fmarri_endreason endreason_l tab a_fmarri_endreason, mi tab a_fmarri_endreason if a_fmarri_endreason >=0 * End year of last marriage a_lmarri_endy gen a_lmarri_endy = . forvalues i= 1/4 { replace a_lmarri_endy = a_lmend`i' if a_lmend`i' != . //define NA values replace a_lmarri_endy = a_lmdvy`i' if a_lmend`i' == 1 & a_lmdvy`i' != . replace a_lmarri_endy = a_lmwwy`i' if a_lmend`i' == 2 & a_lmwwy`i' != . } recode a_lmarri_endy (-9=.) (-7=-8) (97=-8) replace a_lmarri_endy = -8 if mi(a_lmarri_endy) & a_marriage == 2 | (a_marriage == 1 & a_nmar == 1) replace a_lmarri_endy = a_nmar if a_nmar < 0 & mi(a_lmarri_endy) recode a_lmarri_endy (-9=.) (-7=-8) label value a_lmarri_endy numeric_l label var a_lmarri_endy "End Year of Last Marriage" tab a_lmarri_endy,mi sum a_lmarri_endy if a_lmarri_endy >0 * End month of last marriage a_lmarri_endm gen a_lmarri_endm = . forvalues i= 1/4 { replace a_lmarri_endm = a_lmend`i' if a_lmend`i' != . replace a_lmarri_endm = a_lmdvm`i' if a_lmend`i' == 1 & a_lmdvm`i' != . replace a_lmarri_endm = a_lmwwm`i' if a_lmend`i' == 2 & a_lmwwm`i' != . } recode a_lmarri_endm (-9=.) (-7=-8) (97=-8) replace a_lmarri_endm = -8 if mi(a_lmarri_endm) & a_marriage == 2 | (a_marriage == 1 & a_nmar == 1) replace a_lmarri_endm = a_nmar if a_nmar < 0 & mi(a_lmarri_endm) recode a_lmarri_endm (-9=.) (-7=-8) label value a_lmarri_endm numeric_l label var a_lmarri_endm "End Month of Last Marriage" tab a_lmarri_endm,mi tab a_lmarri_endm if a_lmarri_endm >0 * Total number of R's marriages a_marri_times clonevar a_marri_times = a_nmar recode a_marri_times (-9=.) (-7=-8) replace a_marri_times = 0 if a_marstat == 1 label value a_marri_times cmarriy_l label var a_marri_times "Total number of R's Marriage" tab a_marri_times, mi * In first marriage-a_firstmarry a_firstmarri *a_marriage a_marri_times gen a_firstmarri = . replace a_firstmarri = -8 if a_marri_times == -8 | a_marri_times == 0 replace a_firstmarri = -2 if a_marri_times == -2 replace a_firstmarri = -1 if a_marri_times == -1 replace a_firstmarri = 1 if a_marri_times == 1 & a_marriage == 1 replace a_firstmarri = 0 if (a_marri_times == 1 & a_marriage != 1) | /// a_marri_times >1 label var a_firstmarri "In First Marriage" label value a_firstmarri cmarri_coh_l tab a_firstmarri, mi ***************************** *Part.6 Migration ***************************** * Place of birth of R (province/state) a_birthplace *a_ukborn born in uk gen a_birthplace = a_ukborn recode a_birthplace (-9=.) (-7=-8) (5=0) label define birthp_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"Not in the UK" 1"England" 2"Scotland" 3"Wales" 4" Northern Ireland" label value a_birthplace birthp_l label var a_birthplace "Place of birth of R" tab a_birthplace,mi * Place of current residence of R (province/state) a_province *a_gor_dv: Government office Region clonevar a_province = a_gor_dv label var a_province "Place of current residence of R" tab a_province,mi * Proficiency of local language a_language /*a_englang English is first language a_engspk a_spkdif degree of difficulty speaking daytoday english a_engtel a_teldif degree of difficulty speaking english on phone a_engread a_readdif degree of difficulty reading english a_engform a_formdif degree of difficulty completing forms in english*/ /* english ability assessment 1: yes --> next level 2: no -> 0 1: a little difficult --> 1 2: fairly difficult --> 2 3: very difficult --> 3 4: no ability --> 4 */ gen engass_s = . replace engass_s = 0 if a_engspk == 2 replace engass_s = a_spkdif if a_engspk == 1 & a_spkdif > 0 gen engass_t = . replace engass_t = 0 if a_engtel == 2 replace engass_t = a_teldif if a_engtel == 1 & a_teldif > 0 gen engass_r = . replace engass_r = 0 if a_engread == 2 replace engass_r = a_readdif if a_engread == 1 & a_readdif > 0 gen engass_f = . replace engass_f = 0 if a_engform == 2 replace engass_f = a_formdif if a_engform == 2 & a_formdif > 0 /*compute the average [0,1) ->good [1,2) -> fair [2,4] -> bad*/ egen engass = rowmean( engass_s engass_t engass_r engass_f) gen a_language = . label define language_l -8 " Not Applicable" -2 "Refused to Answer" -1 "Don't Know" /// 1 "Native User" 2"Good" 3"Fair" 4"Bad" /*a_englang 1: yes -> native user 2: no -> next level */ replace a_language = a_englang if a_englang == 1 | a_englang <0 recode a_language (-9=.) (-7=-8) replace a_language = 2 if engass >=0 & engass <1 //good replace a_language = 3 if engass >=1 & engass <2 //fair replace a_language = 4 if engass >= 2 & engass <=4 //bad label var a_language "Proficiency of local language" label value a_language language_l tab a_language, mi ***************************** *Part.7 Housing ***************************** * House Ownership (public, subsidized(by government or employer), private, rental) a_house_owner *a_hsownd :house owned or rented gen a_house_owner = . replace a_house_owner = 1 if a_hsownd >= 1 & a_hsownd <= 3 replace a_house_owner = 2 if a_hsownd == 4 replace a_house_owner = 3 if a_hsownd == 97 | a_hsownd == 5 replace a_house_owner = -8 if a_hsownd == -8 replace a_house_owner = -2 if a_hsownd == -2 replace a_house_owner = -1 if a_hsownd == -1 label define housetn_l -8 "Not Applicable" -2 "Refuse to Answer" -1 "Don't Know" /// 1 "Owned by R or R's Family" 2 "Rented" 3 "Others (inc. subsidized by gov. or employer)" label variable a_house_owner "House Ownership" label value a_house_owner housetn_l tab a_house_owner, mi * Housing price a_houseprice *a_hscost from a_hhresp: original purchase price of property clonevar a_houseprice = a_hscost recode a_houseprice (-9=.) label value a_houseprice numeric_l label var a_houseprice "Housing Price" tab a_houseprice if a_houseprice < 0 sum a_houseprice if a_houseprice >=0 insp a_houseprice * Mortgage (yes or no) a_mortgage *a_hsownd: house owned or rented *a_hsyr04: year mortgage began gen a_mortgage = a_hsownd recode a_mortgage (-9=.) (1 3 = 0)(2=1)(4 5 97 = -8) replace a_mortgage = 1 if a_hsownd == 3 & (a_hsyr04 >=-2) label define yesno -8 "Not Applicable" -2 "Refuse to Answer" -1 "Don't Know" /// 1 "Yes" 0 "No" label var a_mortgage "Whether have housing mortgage" label value a_mortgage yesno tab a_mortgage, mi * Year of moving in this house a_moveyear *a_mvyr from a_indresp gen a_moveyear = a_mvyr recode a_moveyear (-9=.) label value a_moveyear numeric_l label var a_moveyear "Year of Moving in This House" tab a_moveyear if a_moveyear < 0 sum a_moveyear if a_moveyear >0 insp a_moveyear ***************************** *Part.8 Health and Well-being ***************************** * Current body weight (kg) a_weight *a_hlwt weight: unit of measurement *a_hlwts weight:stones *a_hlwtp weight:pounds *a_hlwtk weight:kilos gen a_weight = . tab a_hlwts a_hlwtp if a_hlwts <0 | a_hlwtp<0 gen a_hlwtp_temp = a_hlwtp replace a_hlwtp_temp =0 if a_hlwtp_temp < 0 if a_hlwt == 1 { replace a_weight = (a_hlwts*14+a_hlwtp_temp)*0.4536 if a_hlwts >= 0 replace a_weight = a_hlwts if a_hlwts <0 } replace a_weight = a_hlwtk if a_hlwt == 2 replace a_weight = -1 if a_hlwt == 3 replace a_weight = a_hlwt if a_hlwt < 0 recode a_weight (-9=.)(-7=-8) label value a_weight numeric_l label var a_weight "Current Body Weight (kg)" tab a_weight if a_weight < 0 sum a_weight if a_weight > 0 insp a_weight * Current height (cm) a_height *a_hlht height: unit of measurement *a_hlhtf height without shoes: feet *a_hlhti height without shoes: inches *a_hlhtc height without shoes: cms gen a_height = . tab a_hlhtf a_hlhti if a_hlhtf <0 |a_hlhti <0 gen a_hlhti_temp = a_hlhti recode a_hlhti (-1=0) //inches don't know *feet and inches replace a_height = (a_hlhtf*12 +a_hlhti_temp)/0.3937 if a_hlht == 1 replace a_height = -2 if a_hlhtf == -2 replace a_height = -1 if a_hlhtf == -1 *cm replace a_height = a_hlhtc if a_hlht == 2 replace a_height = a_hlht if a_hlht !=1 & a_hlht != 2 recode a_height (-9=.)(-7=-8)(3=-1) label value a_height numeric_l label var a_height "Current Height (cm)" tab a_height if a_height <0 sum a_height if a_height >0 * Self-rated health status a_health *a_sf1 general health drop a_health gen a_health = a_sf1 recode a_health (-9=.) (-7=-8) recode a_health (1/3 = 1 ) (4=2) (5=3) label define health_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1" Good" 2 "Fair" 3"Bad" label value a_health health_l label var a_health "Self-rated Health Status" tab a_health, mi * CES-D depression scale a_cesd * a_sf6c felt downhearted and depressed gen a_depressed = a_sf6c recode a_depressed (-9=.) (-7=-8) label define depress_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1" Always" 2 "Often" 3"Sometimes" 4"Seldom" 5"Never" label value a_depressed depress_l label var a_depressed "Freq. of feeling depressed" tab a_depressed, mi * Self-rated life satisfaction a_lifesat *a_sclfsato: satisfaction with life overall gen a_lifesat = a_sclfsato recode a_lifesat (-9=.)(-7=-8) recode a_lifesat (1=1) (2/3=2) (4=3)(5/6=4)(7=5) label define lifesat_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "Very Dissatisfied" 2" Dissatisfied" 3"Fair" 4"Satisfied" 5 "Very Satisfied" label value a_lifesat lifesat_l label var a_lifesat "Self-rated Life Satisfaction" tab a_lifesat, mi * BMI a_bmi gen a_bmi = . replace a_bmi = a_weight/(a_height/100)^2 if a_weight > 0 &a_height>0 replace a_bmi = a_weight if a_weight < 0 replace a_bmi = a_height if a_height < 0 label value a_bmi numeric_l label var a_bmi "BMI" sum a_bmi if a_bmi >0 tab a_bmi if a_bmi < 0 insp a_bmi save File_UK, replace ***************************************** *Variables w.r.t father, mother & spouse, children ***************************************** *********************Father****************** * Information about Father (derived from A_indresp) use File_UK keep a_hidp a_pno a_birthy a_age a_edu rename a_* a_*_f rename a_pno a_fnpno rename a_hidp_f a_hidp save ukcompute\father, replace use File_UK merge m:1 a_hidp a_fnpno using ukcompute\father drop if _merge == 2 drop _merge ******************************************** * Year of birth of R's father a_birthy_f *a_lvrel2: Living father mentioned or not *a_paage Father's Age: to infer by age replace a_birthy_f = a_syear - a_paage if a_paage >0 replace a_birthy_f = a_paage if a_birthy_f == . & a_paage < 0 recode a_birthy_f (-9=.) (-7 = -8) label var a_birthy_f "Year of birth of R's father" label value a_birthy_f numeric_l tab a_birthy_f, mi sum a_birthy_f if a_birthy_f >0 * Age of R's father a_age_f *a_paage Father's Age replace a_age_f = a_paage if a_paage > 0 replace a_age_f = a_paage if mi(a_age_f) recode a_age_f (-7=-8) (-9=.) label var a_age_f "Age of R's father" labe value a_age_f numeric_l tab a_age_f, mi sum a_age_f if a_age_f >0 * Highest educational level attained by R's father a_edu_f *a_paedqf: father's educational qualifications --- also relevant, but can't unify the standard label var a_edu_f "Highest educational level attained by R's father" tab a_edu_f, mi tab a_edu_f if a_edu_f >=0 * Occupation (ISCO) of R's father when R was a child a_isco_f *a_pasoc10_cc father's occupation (SOC 2010), resp aged 14, condensed 3-digit version clonevar a_isco_f = a_pasoc10_cc label var a_isco_f "Occupation (ISCO) of R's father when R was a child" save File_UK, replace *********************Mother****************** * Information about Mother (derived from A_indresp) use File_UK keep a_hidp a_pno a_birthy a_age a_edu rename a_* a_*_m rename a_pno a_mnpno rename a_hidp_m a_hidp save ukcompute\mother, replace use File_UK merge m:1 a_hidp a_mnpno using ukcompute\mother drop if _merge == 2 drop _merge ******************************************** * Year of birth of R's mother a_birthy_m *a_maage Mother's Age *infer by age replace a_birthy_m = a_syear - a_maage if a_maage >0 replace a_birthy_m = a_maage if a_birthy_m == . & a_maage < 0 recode a_birthy_m (-7=-8) (-9=.) label var a_birthy_m "Year of birth of R's mother" label value a_birthy_m numeric_l tab a_birthy_m, mi sum a_birthy_m if a_birthy_m >0 * Age of R's mother a_age_m *a_maage Mother's Age replace a_age_m = a_maage if a_maage > 0 replace a_age_m = a_maage if mi(a_age_m) & a_maage < 0 recode a_age_m (-7=-8) (-9=.) label var a_age_m "Age of R's mother" labe value a_age_m numeric_l tab a_age_m, mi sum a_age_m if a_age_m >0 * Highest educational level attained by R's mother a_edu_m label var a_edu_m "Highest educational level attained by R's mother" tab a_edu_m, mi tab a_edu_m if a_edu_m >=0 * Occupation (ISCO) of R's mother when R was a child a_isco_m *a_masoc10_cc mother's occupation (SOC 2010), resp aged 14, condensed 3-digit clonevar a_isco_m = a_masoc10_cc label var a_isco_m "Occupation (ISCO) of R's mother when R was a child" save File_UK, replace *********************Spouse****************** * Information about spouse (derived from a_indresp) use File_UK keep pidp a_birthy a_age a_urban a_eduy a_edu a_employ a_isco a_birthplace a_province /// a_language rename a_* a_*_s rename pidp a_sppid save ukcompute\spouse, replace use File_UK merge m:1 a_sppid using ukcompute\spouse drop if _merge == 2 drop _merge ******************************************** * Year of birth of R's spouse a_birthy_s replace a_birthy_s = -8 if mi(a_birthy_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_birthy_s = a_marstat if mi(a_birthy_s) & a_marstat < 0 & !mi(a_marstat) label value a_birthy_s numeric_l label var a_birthy_s "Year of birth of R's spouse" tab a_birthy_s, mi sum a_birthy_s if a_birthy_s > 0 * Age of R's spouse a_age_s replace a_age_s = -8 if mi(a_age_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_age_s = a_marstat if mi(a_age_s) & a_marstat < 0 & !mi(a_marstat) label value a_age_s numeric_l label var a_age_s "Age of R's spouse" tab a_age_s, mi sum a_age_s if a_age_s > 0 * Place of residence of R's spouse (urban or rural) a_urban_s replace a_urban_s = -8 if mi(a_urban_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_urban_s = a_marstat if mi(a_urban_s) & a_marstat < 0 & !mi(a_marstat) label var a_urban_s "Place of residence of R's spouse (urban or rural)" label define a_urban_s -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" 1"Urban Area" 2"Rural Area" label value a_urban_s a_urban_s tab a_urban_s, mi tab a_urban_s if a_urban_s >=0 * Years of schooling of R's spouse a_eduy_s replace a_eduy_s = -8 if mi(a_eduy_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_eduy_s = a_marstat if mi(a_eduy_s) & a_marstat < 0 & !mi(a_marstat) label var a_eduy_s "Years of Schooling of R's spouse" tab a_eduy_s, mi tab a_eduy_s if a_eduy_s > 0 * Highest educational level attained by R's spouse a_edu_s replace a_edu_s = -8 if mi(a_edu_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_edu_s = a_marstat if mi(a_edu_s) & a_marstat < 0 & !mi(a_marstat) label var a_edu_s "Highest Educational Level Attained by R's Spouse" tab a_edu_s, mi tab a_edu_s if a_edu_s >=0 * Employment status of R's spouse a_employ_s replace a_employ_s = -8 if mi(a_employ_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_employ_s = a_marstat if mi(a_employ_s) & a_marstat < 0 & !mi(a_marstat) label var a_employ_s "Employment status of R's spouse" tab a_employ_s, mi tab a_employ_s if a_employ_s >=0 * Place of birth of R's spouse a_birthplace_s replace a_birthplace_s = -8 if mi(a_birthplace_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_birthplace_s = a_marstat if mi(a_birthplace_s) & a_marstat < 0 & !mi(a_marstat) label var a_birthplace_s "Place of birth of R's spouse" tab a_birthplace_s,mi * Occupation of R's spouse replace a_isco_s = -8 if mi(a_isco_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_isco_s = a_marstat if mi(a_isco_s) & a_marstat < 0 & !mi(a_marstat) label var a_isco_s "Occupation of R's spouse's main job" *make frequency table by 100 clonevar a_isco1_s = a_isco_s replace a_isco1_s = int(a_isco1_s/100) if a_isco1_s > 0 label values a_isco1_s isco1 tab a_isco1_s,mi tab a_isco1_s if a_isco1_s >= 0 * Place of current residence of R's spouse a_province_s replace a_province_s = -8 if mi(a_province_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_province_s = a_marstat if mi(a_province_s) & a_marstat < 0 & !mi(a_marstat) label define a_gor_dv -8"Not Applicable" -2"Refused to Anwser" -1"Don't Know", modify label value a_province_s a_gor_dv label var a_province_s "Place of current residence of R's spouse" tab a_province_s,mi tab a_province_s if a_province_s > 0 * Proficiency of local language for R's spouse a_language_s replace a_language_s = -8 if mi(a_language_s) & (a_marstat == 1 | a_marstat >= 4) & !mi(a_marstat) replace a_language_s = a_marstat if mi(a_language_s) & a_marstat < 0 & !mi(a_marstat) label var a_language_s "Proficiency of local language for R's spouse" tab a_language_s,mi tab a_language_s if a_language_s >=0 save File_UK, replace *********************Children****************** * merge A_NATCHILD: birthdate for nonresident children *for resident children, match the person number: a_lchno (with family number) from A_INDALL /*a_lchlv child resident - biological a_lchyd year the biological child died a_lchdoby year of birth of non-resident biological child a_lchno pno of resident biological child*/ use "$datadir\a_natchild" keep a_hidp a_pno a_childno a_lchlv a_lchyd4 a_lchdoby a_lchno rename a_lchyd4 a_lchyd reshape wide a_lchlv a_lchyd a_lchdoby a_lchno, i(a_hidp a_pno) j(a_childno) save ukcompute\child, replace use File_UK merge 1:1 a_hidp a_pno using ukcompute\child drop _merge rename a_natch0* a_natch* save File_UK, replace forvalues i = 1/20 { use "$datadir\a_indall" rename a_pno a_lchno`i' clonevar a_natch`i' = a_lchno`i' save ukcompute\indall, replace use File_UK qui merge m:1 a_hidp a_lchno`i' using ukcompute\indall, keepusing (a_dvage) drop if _merge== 2 drop _merge replace a_lchdoby`i' = a_syear - a_dvage if a_lchno`i' > 0 & !mi(a_lchno`i') drop a_dvage if `i' <=16 { /*for person who don't have children information in A_NATCHILD: directly merge the children DOB from A_INDALL by a_hidp & a_natch* */ qui merge m:1 a_hidp a_natch`i' using ukcompute\indall, keepusing (a_dvage) drop if _merge== 2 drop _merge replace a_lchdoby`i' = a_syear - a_dvage if mi(a_lchdoby`i') & a_dvage >0 &!mi(a_dvage) replace a_lchdoby`i' = -8 if mi(a_lchdoby`i') & a_natch`i' <= 0 drop a_dvage } replace a_lchdoby`i' = -8 if a_child <= 0 replace a_lchdoby`i' = -8 if a_lchdoby`i' > 2010 & !mi(a_lchdoby`i') recode a_lchdoby`i' (-9=.) (-7=-8) gen a_birthy_c`i' = a_lchdoby`i' label value a_birthy_c`i' numeric_l label var a_birthy_c`i' "Year of birth of R's children" save File_UK, replace } * Age of R's children a_age_c1-a_age_c10 *a_lchlv Child in resdent forvalues i = 1/20{ gen a_age_c`i' = . replace a_age_c`i' = a_syear - a_birthy_c`i' if a_birthy_c`i' > 0 replace a_age_c`i' = a_birthy_c`i' if a_birthy_c`i' <0 replace a_age_c`i' = -8 if a_lchlv`i' == 3 //died label var a_age_c`i' "Age of R's Children" label value a_age_c`i' numeric_l } save File_UK, replace ************************************************** keep a_syear a_smonth a_pid a_fid a_pidp a_pweight a_fweight /// a_birthy a_age a_gender a_ethnica a_ethnicb a_urban a_sib a_child /// a_eduy a_edu /// a_employ a_workhour_week a_isco a_isco_first a_monthinc a_hourwage a_yearinc1 a_yearinc2 a_pensioninc a_income a_tenure a_jobsat /// a_gen a_fsize a_fstruc a_hhstruc a_faminc_post a_faminc_pre /// a_marriage a_cmarri_y a_cmarri_m a_cmarri_cohab a_cmarri_cohabd a_fmarri_y a_fmarri_m a_fmarri_cohab a_fmarri_endy a_fmarri_endm a_fmarri_endreason a_lmarri_endy a_lmarri_endm a_marri_times a_firstmarri /// a_birthplace a_province a_language /// a_house_owner a_houseprice a_mortgage a_moveyear /// a_weight a_height a_health a_depressed a_lifesat a_bmi /// a_birthy_f a_age_f a_edu_f a_isco_f a_birthy_m a_age_m a_edu_m a_isco_m /// a_birthy_s a_age_s a_urban_s a_eduy_s a_edu_s a_employ_s a_isco_s a_birthplace_s a_province_s a_language_s /// a_birthy_c* a_age_c1-a_age_c20 save File_UK, replace