**code written by Renzo Carriero, University of Torino - Italy. 11th June 2015 ** ADAPTED BY MARGA mtus x data ***********05/2018 c save "C:\Users\Test\Desktop\ITALIAN\matriceusotempo2008_ind_ep_individui.dta", replace g nchild=1 if I_eta<18 g agekidx=I_eta if I_eta<18 replace agekidx=I_eta if I_eta>=18 & (I_parent_pr==6 | I_parent_pr==7 | I_parent_pr==10 | I_parent_pr==11) /*agekidx takes on values >=18 only for hh members who are son/daughter of someone in the hh*/ *the following vars will serve to map parents of someone else living in the home g id_pr=nordcomp if I_parent_pr==1 /*father/mother (RP)*/ g id_partpr=nordcomp if I_parent_pr==2 | I_parent_pr==2 /*his/her partner*/ g id_genit=nordcomp if I_parent_pr==4 /*granfather/mother*/ g id_genit_part=nordcomp if I_parent_pr==5 /*mother/father in law*/ g id_figlio=nordcomp if I_parent_pr==6 | I_parent_pr==7 /*dauther/son (if case s/he lives with their children and parents*/ g id_part_figlio=nordcomp if I_parent_pr==8 | I_parent_pr==8 /*spouse of dauther/son (if case s/he lives with their children and parents*/ g id_fratsor=nordcomp if I_parent_pr==12 /*uncle/aunt*/ g id_part_fratsor=nordcomp if I_parent_pr==14 | I_parent_pr==15 /*partner of uncle/aunt*/ g coppia=1 if I_nucleo==1 | I_nucleo==2 /*create an auxiliary variable to identify hhld where there is a couple (to be used to create hhtype)*/ collapse (sum) nchild (min) agekid2=agekidx id_pr=id_pr id_partpr=id_partpr id_genit1=id_genit id_genit_part1=id_genit_part id_figlio=id_figlio /// id_part_figlio=id_part_figlio id_fratsor=id_fratsor id_part_fratsor=id_part_fratsor (max) id_genit2=id_genit id_genit_part2=id_genit_part coppia=coppia, by(progfam) recode agekid2 (60/max=60) recode agekid2 (0/4=1 "0-4") (5/12=2 "5-12") (13/17=3 "13-17") (18/max=4 "18+"), gen(agekidx) replace agekid2=-7 if agekid2==. replace agekidx=-7 if agekidx==. merge 1:m progfam using "C:\Users\Test\Desktop\ITALIAN\matriceusotempo2008_ind_ep_individui.dta" order nchild-agekidx I_nucleo I_n_nucleo ponuc I_tipo_fam I_parent_pr, after(progfam) g hhldsize=I_ncomp g str2 country="IT" g survey=2008 g swave=0 g msamp=0 g hldid=progfam g persid=nordcomp g id=1 sort progfam I_n_nucleo ponuc g partid=nordcomp[_n+1] if ponuc==1 & (I_nucleo==1 | I_nucleo==2) & ponuc[_n+1]==2 & progfam==progfam[_n+1] & I_n_nucleo==I_n_nucleo[_n+1] replace partid=nordcomp[_n-1] if ponuc==2 & (I_nucleo==1 | I_nucleo==2) & ponuc[_n-1]==1 & progfam==progfam[_n-1] & I_n_nucleo==I_n_nucleo[_n-1] replace partid=-7 if partid==. drop _merge save "C:\Users\Test\Desktop\ITALIAN\it2008bv_prov.dta", replace g parntid1=id_pr if (I_parent_pr==6 | I_parent_pr==7) /*assign parent's id1 to children*/ g parntid2=id_partpr if (I_parent_pr==6 | I_parent_pr==7) /*assign parent's id1 to children*/ replace parntid1=id_genit1 if I_parent_pr==1 /*assign parent's id1 to children when they are RP*/ replace parntid2=id_genit2 if I_parent_pr==1 /*assign parent's id1 to children when they are RP*/ replace parntid1=id_genit_part1 if (I_parent_pr==2 | I_parent_pr==3) /*assign parent's id1 to child's spouse (mother/father in law for the the child)*/ replace parntid2=id_genit_part2 if (I_parent_pr==2 | I_parent_pr==3) /*assign parent's id2 to child's spouse (mother/father in law for the the child)*/ replace parntid1=id_figlio if (I_parent_pr==10) /*assign parent's id1 to grandchildren*/ replace parntid2=id_part_figlio if (I_parent_pr==10) /*assign parent's id1 to grandchildren*/ replace parntid1=id_fratsor if (I_parent_pr==11) /*assign parent's id1 to nephew when uncle/aunt withe their children are in the hhld*/ replace parntid2=id_part_fratsor if (I_parent_pr==11) /*assign parent's id1 to nephew when uncle/aunt withe their children are in the hhld*/ replace parntid1=id_genit1 if I_parent_pr==12 /*assign parent's id1 to child's sibling when child is RP (unclear why, but correct)*/ replace parntid2=id_genit2 if I_parent_pr==12 /*assign parent's id1 to child's sibling when child is RP (unclear why, but correct)*/ replace parntid1=id_genit_part1 if I_parent_pr==13 /*assign parent's id1 to child's sibling when child is RP (unclear why, but correct)*/ replace parntid2=id_genit_part2 if I_parent_pr==13 /*assign parent's id1 to child's sibling when child is RP (unclear why, but correct)*/ replace parntid1=-7 if parntid1==. replace parntid2=-7 if parntid2==. | parntid2==parntid1 replace parntid1=parntid2 if parntid2!=. & parntid2!=-7 & parntid1==-7 g parntid1p=parntid1 if parntid1>parntid2 & parntid2!=-7 /*code to assign lower parnt id on parntid1*/ g parntid2p=parntid2 if parntid1>parntid2 & parntid2!=-7 /*code to assignlower parnt id on parntid1*/ replace parntid1=parntid2p if parntid1p>parntid2p & parntid2p!=-7 /*code to assign lower parnt id on parntid1*/ replace parntid2=parntid1p if parntid1p>parntid2p & parntid2p!=-7 /*code to assign lower parnt id on parntid1*/ *replace "by hand" 1 case not findable with previous code replace parntid1=5 if progfam==4719 & nordcomp==6 drop parntid1p parntid2p tab parntid1 parntid2 /*9 cases to check for same parntid*/ replace parntid2=-7 if parntid1==parntid2 & parntid1!=-7 & parntid2!=-7 /*8 are newphes of RP living with one parent in RP hhld*/ replace parntid1=5 if progfam==11621 & nordcomp==7 /*1 case corrected; it's a nephew of RP living with both parents in RP hhld*/ /* There are 42 cases of grandchildren to whom parents's id cannot be assigned because actually they don't live with their parents, but with their granparents; most of them are adult (18+) There are 23 cases of nephews (children of brother or sister of the reference person) to whom parents's id cannot be assigned because actually they don't live with their parents; 8 of them are under 18 years*/ g hhtype=1 if I_ncomp==1 /*variable I_comp records number of people in household (=hhld size)*/ replace hhtype=2 if I_ncomp==2 & I_nucleo==2 & coppia==1/*var I_nucleo identify types of nuclear families 2=couple with no children*/ replace hhtype=3 if I_ncomp>2 & coppia==1 /*hhldsize>2 and presence of a couple within hhld*/ replace hhtype=4 if I_ncomp>=2 & coppia!=1 /*hhldsize>=2 and NO couples within hhld*/ g incorig=-9 /*no available income variable in ISTAT file, altough the question was asked*/ g income=-9 /*no available income variable in ISTAT file, altough the question was asked*/ recode F_titgodab (2=1 "own") (1=2 "rent") (3/5=3 "other arrangement"), gen(ownhome) recode I_amp_centro (1 2 5 6=1 "Urban/suburban") (3 4=2 "rural/semi-rural"), gen(urban) *Urban/rural cannot be defined on the grounds of size of municipality only; I coded as urban municipalities classified as "metropolitan city" and their suburbs *and municipalities with more than 10K inhabitants. I classified the remainder (mun. with less than 10K) as rural. g computer=F_computer==2 | F_internet==4 g vehicle=0 if F_auto==3 & F_motorino==7 & F_moto==1 egen nvehicle=rowmin(F_n_motorino F_n_moto F_n_auto) replace vehicle=3 if nvehicle==1 replace vehicle=4 if nvehicle>1 & nvehicle<. recode I_sesso (1=1 "man") (2=2 "woman"), gen(sex) recode I_eta (90/max=90), gen(age) g famstat=0 if I_eta>=18 & I_eta<=39 & (agekidx==-7 | agekidx==4) replace famstat=1 if I_eta>=18 & agekidx==1 replace famstat=2 if I_eta>=18 & (agekidx==2 | agekidx==3) replace famstat=3 if I_eta>=40 & (agekidx==-7 | agekidx==4) replace famstat=4 if I_eta<18 & (I_parent_pr==6 | I_parent_pr==7 | I_parent_pr==10 | I_parent_pr==11) /*child<18 classified as child or nephew or grandchild of the reference person of the hhld*/ replace famstat=5 if I_eta<18 & (I_parent_pr!=6 & I_parent_pr!=7 & I_parent_pr!=10 & I_parent_pr!=11) g singpar=((I_nucleo==3 | I_nucleo==4) & ponuc==1) recode I_parent_pr (1=1 "Person 1") (2 3=2 "Spouse/ common-law partner") (6 7=3 "Child") (4=4 "Parent") (5=7 "Father/Mother-in-law") (12=5 "Sibling") /// (8 9=6 "Son/Daughter-in-law") (13 14 15=8 "Brother/Sister-in-law") (16 10 11=9 "Other relative") (17=10 "Not related"), gen(relrefp) g civstat=(I_nucleo==1 | I_nucleo==2) & (ponuc==1 | ponuc==2) replace civstat=2 if civstat==0 g cohab=civstat==1 & I_stat_civ!=2 /*I_stat_civ records individual civil status (2=married)*/ replace cohab=-7 if civstat==2 g citizen=I_cittadinanza==1 g empstat=1 if I_temp_lav==1 replace empstat=2 if I_temp_lav==2 replace empstat=4 if I_cond_prof!=1 *it is not possible to distinguish student or unemployed working at least some hours g emp=empstat<4 g unemployed=I_cond_prof==2 | I_cond_prof==3 g student=I_formazione!=1 /*notice that the question on school enrolment refers to the current academic year or the one just finished, so there can be cases of diarists classified as students (if the question was asked during summer holiday), although they are not currently students and are instead employed or unemployed (looking for a job) notice also that most children aged 3 years + are classified as student*/ g retired=I_cond_prof==7 /*information on retirement is derived from a variable about current main or unique employment status, it cannot distinguish between working and non-working retired people*/ g empsp_m=empstat if civstat==1 & I_sesso==1 g empsp_f=empstat if civstat==1 & I_sesso==2 save "C:\Users\Test\Desktop\ITALIAN\it2008bv_prov.dta", replace collapse empsp_m=empsp_m empsp_f=empsp_f, by(progfam I_n_nucleo) merge 1:m progfam I_n_nucleo using "C:\Users\Test\Desktop\ITALIAN\it2008bv_prov.dta" sort progfam nordcomp g empsp=empsp_m if civstat==1 & I_sesso==2 replace empsp=empsp_f if civstat==1 & I_sesso==1 replace empsp=-7 if civstat==2 drop empsp_m empsp_f g workhrs=I_ALTR_LAV_ore /*whorkhrs takes on values from question on reported usual work hours*/ replace workhrs=-8 if I_ALTR_LAV_altro==8 | I_ALTR_LAV_altro==9 replace workhrs=-7 if I_cond_prof!=1 g empinclm=-9 g occupo=I_cod_prof_ISTAT /*NOTE: 14=managers of firms of unknown size*/ replace occupo=-7 if I_cond_prof!=1 replace occupo=-8 if occupo==. & I_cond_prof==1 *Label in Italian in a separate file; *only employed people; no codes for past job (only aggregate categories in separate variable; do not allow even 1-digit classification of manual occupations) /*the Italian classification of occupation 2001 (the one used at that time, now updated in 2011) is very similar to the isco08, but data are provided only at 2 digit, so it is not possible to use the exact conversion table provided by ISTAT which works only with 4-digit codes. A few miscodings are possible, although should be rare */ replace occupo=101 if I_ULTLAV_POSPROF_DIP==1 replace occupo=102 if I_ULTLAV_POSPROF_DIP==2 replace occupo=103 if I_ULTLAV_POSPROF_DIP==3 replace occupo=104 if I_ULTLAV_POSPROF_DIP==4 replace occupo=105 if I_ULTLAV_POSPROF_DIP==5 replace occupo=106 if I_ULTLAV_POSPROF_DIP==6 replace occupo=107 if I_ULTLAV_POSPROF_DIP==7 replace occupo=108 if I_ULTLAV_POSPROF_DIP==8 replace occupo=112 if I_ULTLAV_POS_OCC==2 replace occupo=113 if I_ULTLAV_POS_OCC==3 replace occupo=114 if I_ULTLAV_POS_OCC==4 replace occupo=115 if I_ULTLAV_POS_OCC==5 replace occupo=116 if I_ULTLAV_POS_OCC==6 replace occupo=117 if I_ULTLAV_POS_OCC==7 replace occupo=118 if I_ULTLAV_POS_OCC==8 recode occupo (90=0 "Armed forces occupations") (1 11 12 13 14 101 114=1 "Managers, senior officials and legislators") (21/26 103 104 115=2 "Professionals") /// (3 31/34=3 "Technicians and associate professionals") (4 41 42 102 105=4 "Clerical workers") (5 51/55=5 "Service and sales workers") /// (64=6 "Skilled agricultural, fishery and forestry workers") (6 61 62 63 65 66=7 "Craft and related trade workers") (7 71/74=8 "Plant and machine operators and assemblers") /// (8 81/86 106 107 108=9 "Elementary occupations"), gen(isco1) replace isco1=6 if occupo>=116 & occupo<=118 & I_ULTLAV_ATECO==1 /*self-employed in primary sector go into isco1=6*/ replace isco1=5 if occupo>=116 & occupo<=118 & (I_ULTLAV_ATECO==5 | I_ULTLAV_ATECO==6) /*self-employed in sales or restaurant sector go into isco1=5*/ replace isco1=7 if occupo>=116 & occupo<=118 & (I_ULTLAV_ATECO>=2 & I_ULTLAV_ATECO<=4) /*self-employed in industry, construction and extraction sector go into isco1=7*/ replace isco1=4 if occupo>=116 & occupo<=118 & (I_ULTLAV_ATECO>6 & I_ULTLAV_ATECO<.) & I_tit_stud<6 /*self-employed in other sector go into isco1=4 if they have tertiary education*/ replace isco1=7 if occupo>=116 & occupo<=118 & (I_ULTLAV_ATECO==7) & I_tit_stud>=6 /*self-employed in trasport and communication go into isco1=7 if they have less than tertiary education (they might be mostly truck drivers)*/ replace isco1=9 if occupo>=116 & occupo<=118 & (I_ULTLAV_ATECO>7 & I_ULTLAV_ATECO<.) & I_tit_stud>=6 /*self-employed with less than tertiary education in other sector (also other than transport) are almost impossibile to classify at 1 digit; I coded them as 9 (elementary occ.)*/ replace isco1=4 if (occupo==112 | occupo==113) & I_tit_stud>=6 /*atypical employees coded as isco1=4 if they have tertiary education*/ replace isco1=5 if (occupo==112 | occupo==113) & I_tit_stud<6 & (I_ULTLAV_ATECO==5 | I_ULTLAV_ATECO==6) /*atypical employees coded as isco1=5 if they have less than tertiary education & worked in sales or restaurant sector*/ replace isco1=9 if (occupo==112 | occupo==113) & I_tit_stud<6 & (I_ULTLAV_ATECO!=5 & I_ULTLAV_ATECO!=6) /*atypical employees coded as isco1=9 if they have less than tertiary education & did not work in sales or restaurant sector*/ g sector=1 if I_sett_ateco==10 | I_pubb_priv==1 replace sector=2 if I_sett_ateco!=10 & I_sett_ateco<. replace sector=-7 if I_cond_prof!=1 replace sector=-8 if I_sett_ateco==. & I_cond_prof==1 g educa=I_tit_stud /*original level of education variable; labels in separate file*/ replace educa=-7 if educa==. /*children under 6 are not asked the level of education (although they can be considered as "students"*/ recode educa (9/12=1 "uncompleted secondary or less") (6/8=2 "completed secondary") (1/5=3 "above secondary") , gen(edcat) recode D_stress (1 2=2 "Often") (3=1 "Sometimes") (4=0 "Almost never") (.=-8), gen(rushed) replace rushed=-7 if age<15 *The original question is "Generally, do feel stressed?" recode D_cond_sal (1=3 "Very good") (2=2 "Good") (3=1 "Fair") (4 5=0 "Poor"), gen(health) replace health=-7 if age<3 *The original question is "In general, how is your health?". Answers on 1-Very good to 5-Very bad scale (with intermediate labelled points) g carer=-9 recode D_limitazioni (1=1 "Yes") (2 3=0 "No") (.=-8), gen(disab) replace disab=-7 if age<3 /*The original question is : "Do you have limitations in daily activities because of health problems lasting at least 6 months?" 1=Yes, severe limitations 2=Yes, not serious limitations 3=No limitations"*/ drop _merge sort hldid persid egen persid2 = concat(hldid persid) destring persid2, replace gen region= I_macroarea label values region 10"piemonte" 30 "Lombardia" 40 "Trentino" 50 "Veneto" 60 "Friuli Vnezia Guiulia" 70 "Liguria" 80 "Emilia romagna" 90 "toscana" 100 "Umbria" 110 "Marche" 120 "Lazio" 130 "Abruzzo" 140 "Molise" 150 "Campania" 160 "Puglia" 170 "Basilicata" 180 "Calabria" 190 "Sicilia" 200 "sardegna" gen ethnic = -9 gen migrantd =-9 gen migrantdm=-9 gen migrantdf =-9 keep country survey swave msamp hldid persid incorig region empinclm occupo educa ethnic migrantd migrantdm migrantdf save "C:\Users\Test\Documents\MTUS_X\Italia\2008\mtus\mtus_x\survey_ita_08.dta,replace