clear set memory 150m set matsize 2500 set more off /* ********************************************************************************************************************** */ /* ********************************************************************************************************************** */ /* Jens Hainmueller and Michael J. Hiscox 2004: Educated Preferences: Explaining Attitudes Toward Immigration in Europe */ /* Do File 0: Recodings from the scratch dataset --> final working/replication dataset */ /* Version 1.2 09/10/2004 */ /* using file: ESS1E05_F1.dta */ /* Title : European Social Survey 2002/2003, edition vol 5 */ /* Source : http://129.177.90.106:80 - retrieved 08/31/04 */ /* ********************************************************************************************************************** */ /* This do file sets up all variables used in our analysis starting from the raw ESSdataset as provided on the ESSwebsite */ /* For successful replication please follow these steps in order: */ /* Step 1: Copy "ESS1E05_F1.dta" (the original ESS data file) into your STATA working directory */ /* Step 2: Copy "externalvars.dta" (the downloadable data containing our external vars) into your STATA working directory */ /* (these external variables will be automatically merged in using this do file) */ /* Step 3: Run this do file */ /* You will end up with "ESSvol5recodedHH2004.dta" the exact same dataset as the one readily available for download */ /* Step 4: Run all other do.files on this recoded dataset for replication of all our results */ /* Thank you for your interest in our research */ /* For questions please email: Jens_Hainmueller@ksg05.harvard.edu */ /* ********************************************************************************************************************** */ /* ********************************************************************************************************************** */ use "ESS1E05_F1.dta", clear /* Delete Unnecessary Vars */ keep name edition proddate cntry idno eimrcnt eimpcnt imrcntr impcntr empl pdwrk edctn uempla uempli dsbld rtrd cmsrv hswrk dngoth mainact uemp3m uemp12m uemp5yr regionat-regionsi pweight dweight edulvl eduyrs brwmny iscoco yrbrn gndr hinctnt hincfel lrscale brncntr imgfrnd acetalv qfimwht imwbcrm lwpeth imueclt pplstrd imbgeco imtcjob imbleco ppltrst ginveco ipeqopt iphlppl imptrad sclact rlgdgr gvrfgap shrrfg smbtjob mbtru /* Dependent Variables Binary & Ordered 4 point scale */ /* Richer Europe */ gen iricheur1=1 if eimrcnt==1 | eimrcnt==2 replace iricheur1=0 if eimrcnt==3 | eimrcnt==4 gen iricheur_ordprobit=4 if eimrcnt==1 replace iricheur_ordprobit=3 if eimrcnt==2 replace iricheur_ordprobit=2 if eimrcnt==3 replace iricheur_ordprobit=1 if eimrcnt==4 /* Poorer Europe */ gen ipooreur1 =1 if eimpcnt==1 | eimpcnt==2 replace ipooreur1 =0 if eimpcnt==3 | eimpcnt==4 gen ipooreur_ordprobit=4 if eimpcnt==1 replace ipooreur_ordprobit=3 if eimpcnt==2 replace ipooreur_ordprobit=2 if eimpcnt==3 replace ipooreur_ordprobit=1 if eimpcnt==4 /* Richer Non-Europe */ gen irichnoeur1=1 if imrcntr==1 | imrcntr==2 replace irichnoeur1=0 if imrcntr==3 | imrcntr==4 gen irichnoeur_ordprobit=4 if imrcntr==1 replace irichnoeur_ordprobit=3 if imrcntr==2 replace irichnoeur_ordprobit=2 if imrcntr==3 replace irichnoeur_ordprobit=1 if imrcntr==4 /* Poorer Non-Europe */ gen ipoornoeur1=1 if impcntr==1 | impcntr==2 replace ipoornoeur1=0 if impcntr==3 | impcntr==4 gen ipoornoeur_ordprobit=4 if impcntr==1 replace ipoornoeur_ordprobit=3 if impcntr==2 replace ipoornoeur_ordprobit=2 if impcntr==3 replace ipoornoeur_ordprobit=1 if impcntr==4 /* Sample Weight */ gen CNTRY=cntry gen DWEIGHT=dweight gen PWEIGHT=pweight gen PDWEIGHT=pweight*dweight /* Covariates Benchmark */ gen eduattain=edulvl gen schooling=eduyrs gen age=2003-yrbrn /* Erroneously few <16y olds ended up in the ESS data although the survey sample is representative only of the pop. of >=16y olds */ /* We therefore deleted these obs */ drop if age<16 gen age2=age*age gen gender=1 if gndr==2 replace gender=0 if gndr==1 gen income = hinctnt /* Perceived Income */ gen perincome=4 if hincfel==1 replace perincome=3 if hincfel==2 replace perincome=2 if hincfel==3 replace perincome=1 if hincfel==4 gen native=1 if brncntr==1 replace native=0 if brncntr==2 gen immigrant_friends=1 if imgfrnd==3 replace immigrant_friends=2 if imgfrnd==2 replace immigrant_friends=3 if imgfrnd==1 gen minority_area=acetalv gen partisan_right=lrscale /* Skill Proxies */ gen isocode =iscoco gen skill5=. replace skill5=1 if isocode>=1000 & isocode<2000 replace skill5=0 if skill5~=1 replace skill5=. if isocode<1000 replace skill5=. if isocode==. gen skill4=. replace skill4=1 if isocode>=2000 & isocode<3000 replace skill4=0 if skill4~=1 replace skill4=. if isocode<1000 replace skill4=. if isocode==. gen skill3=. replace skill3=1 if isocode>=3000 & isocode<4000 replace skill3=0 if skill3~=1 replace skill3=. if isocode<1000 replace skill3=. if isocode==. gen skill2=. replace skill2=1 if isocode>=4000 & isocode<9000 replace skill2=0 if skill2~=1 replace skill2=. if isocode<1000 replace skill2=. if isocode==. gen skill1=. replace skill1=1 if isocode>=9000 & isocode<. replace skill1=0 if skill1~=1 replace skill1=. if isocode<1000 replace skill1=. if isocode==. gen skill345=. replace skill345=1 if skill5==1 | skill4==1 | skill3==1 replace skill345=0 if skill1==1 | skill2==1 replace skill345=. if isocode<1000 replace skill345=. if isocode==. /* Additional Covariates (Table 8 ) */ gen ELEMENTARY=1 if edulvl==1 replace ELEMENTARY=0 if edulvl~=1 replace ELEMENTARY=. if edulvl==. gen HIGHSCHOOL =1 if edulvl==3 replace HIGHSCHOOL =0 if edulvl~=3 replace HIGHSCHOOL =. if edulvl==. gen COLLEGE =1 if edulvl==5 replace COLLEGE =0 if edulvl~=5 replace COLLEGE =. if edulvl==. gen PHD=1 if edulvl==6 replace PHD=0 if edulvl~=6 replace PHD=. if edulvl==. /* Additional Covariates (Table 10 ) */ gen racism=qfimwht gen crime=10 if imwbcrm==0 replace crime=9 if imwbcrm==1 replace crime=8 if imwbcrm==2 replace crime=7 if imwbcrm==3 replace crime=6 if imwbcrm==4 replace crime=5 if imwbcrm==5 replace crime=4 if imwbcrm==6 replace crime=3 if imwbcrm==7 replace crime=2 if imwbcrm==8 replace crime=1 if imwbcrm==9 replace crime=0 if imwbcrm==10 gen antihate=lwpeth gen culture=imueclt gen multiculti=pplstrd gen economy=imbgeco /* Additional Covariates Robustness */ gen TRUST=ppltrst gen FREEMARKET=1 if ginveco==5 replace FREEMARKET=2 if ginveco==4 replace FREEMARKET=3 if ginveco==3 replace FREEMARKET=4 if ginveco==2 replace FREEMARKET=5 if ginveco==1 gen EQUALITY=1 if ipeqopt==6 replace EQUALITY=2 if ipeqopt==5 replace EQUALITY=3 if ipeqopt==4 replace EQUALITY=4 if ipeqopt==3 replace EQUALITY=5 if ipeqopt==2 replace EQUALITY=6 if ipeqopt==1 gen ALTRUSIM=1 if iphlppl==6 replace ALTRUSIM=2 if iphlppl==5 replace ALTRUSIM=3 if iphlppl==4 replace ALTRUSIM=4 if iphlppl==3 replace ALTRUSIM=5 if iphlppl==2 replace ALTRUSIM=6 if iphlppl==1 gen TRADITIONALISM=1 if imptrad==6 replace TRADITIONALISM=2 if imptrad==5 replace TRADITIONALISM=3 if imptrad==4 replace TRADITIONALISM=4 if imptrad==3 replace TRADITIONALISM=5 if imptrad==2 replace TRADITIONALISM=6 if imptrad==1 gen RELIGIOUS=rlgdgr gen SCAPITAL1=sclact gen SCAPITAL2=brwmny gen REFUGEE1=1 if gvrfgap==5 replace REFUGEE1=2 if gvrfgap==4 replace REFUGEE1=3 if gvrfgap==3 replace REFUGEE1=4 if gvrfgap==2 replace REFUGEE1=5 if gvrfgap==1 gen REFUGEE2=shrrfg gen TUMEMBER=1 if mbtru==1 replace TUMEMBER=0 if mbtru==2 | mbtru==3 gen eduattainXminority_area=eduattain*minority_area gen schoolingXminority_area=schooling*minority_area /* Labour Market Risk & Sample Delimiters */ replace uemp3m=0 if uemp3m==2 gen mobility=smbtjob gen paidwork=pdwrk gen UEMPLA=uempla gen RTRD=rtrd gen EDCTN=edctn gen UEMPLI=uempli /* Regional Indicators for clustering of SEs */ gen REGIONLU=regionlu gen REGIONNO=regionno gen REGIONCH=regionch gen REGIONIE=regionie gen REGIONDK=regiondk gen REGIONBE=regionbe gen REGIONNL=regionnl gen REGIONDE=regionde gen REGIONFI=regionfi gen REGIONSE=regionse gen REGIONIT=regionit gen REGIONGB=regiongb gen REGIONIL=regionil gen REGIONES=regiones gen REGIONPT=regionpt gen REGIONSI=regionsi gen REGIONGR=regiongr gen REGIONCZ=regioncz gen REGIONHU=regionhu gen REGIONPL=regionpl gen REGIONAT=regionat gen REGIONFR=regionfr replace REGIONLU =0 if CNTRY~="LU" replace REGIONNO =0 if CNTRY~="NO" replace REGIONIE =0 if CNTRY~="IE" replace REGIONDK =0 if CNTRY~="DK" replace REGIONCH =0 if CNTRY~="CH" replace REGIONAT =0 if CNTRY~="AT" replace REGIONNL =0 if CNTRY~="NL" replace REGIONBE =0 if CNTRY~="BE" replace REGIONDE =0 if CNTRY~="DE" replace REGIONFR =0 if CNTRY~="FR" replace REGIONFI =0 if CNTRY~="FI" replace REGIONIT =0 if CNTRY~="IT" replace REGIONGB =0 if CNTRY~="GB" replace REGIONSE =0 if CNTRY~="SE" replace REGIONIL =0 if CNTRY~="IL" replace REGIONES =0 if CNTRY~="ES" replace REGIONPT =0 if CNTRY~="PT" replace REGIONGR =0 if CNTRY~="GR" replace REGIONSI =0 if CNTRY~="SI" replace REGIONCZ =0 if CNTRY~="CZ" replace REGIONHU =0 if CNTRY~="HU" replace REGIONPL =0 if CNTRY~="PL" encode cntry, gen(CCODE) replace CCODE= CCODE*10000 gen REGINDICATOR= CCODE + REGIONLU + REGIONNO + REGIONIE + REGIONDK + REGIONCH + REGIONAT + REGIONNL + REGIONBE + REGIONDE + REGIONFR + REGIONFI + REGIONIT + REGIONGB + REGIONSE + REGIONIL + REGIONES + REGIONPT + REGIONGR + REGIONSI + REGIONCZ + REGIONHU +REGIONPL drop REGION* gen REGIONLU=regionlu gen REGIONNO=regionno gen REGIONCH=regionch gen REGIONIE=regionie gen REGIONDK=regiondk gen REGIONBE=regionbe gen REGIONNL=regionnl gen REGIONDE=regionde gen REGIONFI=regionfi gen REGIONSE=regionse gen REGIONIT=regionit gen REGIONGB=regiongb gen REGIONIL=regionil gen REGIONES=regiones gen REGIONPT=regionpt gen REGIONSI=regionsi gen REGIONGR=regiongr gen REGIONCZ=regioncz gen REGIONHU=regionhu gen REGIONPL=regionpl gen REGIONAT=regionat gen REGIONFR=regionfr sort idno cntry save "ESSvol5recodedHH2004.dta", replace /* Merging in Outside Variables (please copy externalvars.dta in you STATA working directory) */ use "externalvars.dta", clear rename IDNO idno rename CNTRY cntry drop NAME EDITION PRODDATE s2 s_comp sort idno cntry save "externalvarssorted.dta", replace use "ESSvol5recodedHH2004.dta", clear sort idno cntry merge idno cntry using "externalvarssorted.dta" tab _merge drop if _merge==2 drop _merge save "ESSvol5recodedHH2004.dta", replace /* Labeling */ /* Data */ label data "Replication Data HH2004 Educated Preferences-Jens_Hainmueller@ksg05.harvard.edu" /* DVs */ label var iricheur1 "BinaryDV: Allow Immigration from Richer Europe" label var ipooreur1 "BinaryDV: Allow Immigration from Poorer Europe" label var irichnoeur1 "BinaryDV: Allow Immigration from Richer Outside-Europe" label var ipoornoeur1 "BinaryDV: Allow Immigration from Poorer Outside-Europe" label define DV 0 Allow_none_or_Allow_a_few 1 Allow_some_or_Allow_many label values iricheur1 DV label values ipooreur1 DV label values irichnoeur1 DV label values ipoornoeur1 DV label var iricheur_ordprobit "DVOrdProbit: Allow Immigration from Richer Europe" label var ipooreur_ordprobit "DVOrdProbit: Allow Immigration from Poorer Europe" label var irichnoeur_ordprobit "DVOrdProbit: Allow Immigration from Richer Outside-Europe" label var ipoornoeur_ordprobit "DVOrdProbit: Allow Immigration from Poorer Outside-Europe" label define DVord 1 Allow_none 2 Allow_a_few 3 Allow_some 4 Allow_many label values iricheur_ordprobit DVord label values ipooreur_ordprobit DVord label values irichnoeur_ordprobit DVord label values ipoornoeur_ordprobit DVord /* Covars */ label values eduattain edulvl label var eduattain "Educational Attainment" label var schooling "Years of Schooling" label var age2 "age^2" label define gender 0 Male 1 Female label values gender gender label define income 1 Less_than_150Eur 2 150_to_under300Eur 3 300_to_under_500Eur 4 500_to_under_1000Eur 5 1000_to_under_1500Eur 6 1500_to_under_2000Eur 7 2000_to_under_2500 8 2500_to_under_3000 9 3000_to_under_5000 10 5000_to_under_7500Eur 11 7500_to_under_10000Eur 12 10000_or_more label values income income label var income "monthly household income" label var perincome "Perceived Income" label define perincome 1 Very_difficult_on_present_income 2 Difficult_on_present_income 3 Coping_on_present_income 4 Living_comfortably_on_present_income label values perincome perincome label var native "born in this country?" label define native 0 No 1 Yes label values native native label var immigrant_friends "Any immigrant friends?" label define imgf 1 None_at_all 2 A_Few 3 Several label values immigrant_friends imgf label var skill345 "High/Low Skill dummy" label define skill345 1 High_Skill 0 Low_Skill label values skill345 skill345 label values minority_area acetalv label var minority_area "Living in area with..." label values partisan_right lrscale label var partisan_right "Placement on Left/Right scale" label var PDWEIGHT "Design * Population Weight" label values racism qfimwht label var racism "Qualifcation for Immigrants: be white?" label values antihate lwpeth label var antihate "Law_against_promoting_racial_hatred" label values culture imueclt label var culture "Immigrants undermine or enrich culture" label var multiculti pplstrd label var multiculti "Better if everybody shares same values/traditions?" label values economy imbgeco label var economy "Economic Literacy: Img. good for economy as a whole?" label var crime "Immigration makes crime problems better/worse?" label define crime 10 Crime_Problems_worse 0 Crime_Problems_better label values crime crime /* Extended Covars */ label values TRUST ppltrst label var TRUST "Most people can be trusted?" label var FREEMARKET "The less government intervenes in economy, the better for country" label define FREEMAR 5 Agree_Strongly 0 Disagree_Strongly label values FREEMARKET FREEMAR label var EQUALITY "Important that people are treated equally and have equal opportunities" label var ALTRUSIM "Important to help people and care for others well-being" label var TRADITIONALISM "Important to follow traditions and customs" label define VALUES 1 Not_like_me_at_all 2 Not_like_me 3 A_little_like_me 4 Somewhat_like_me 5 Like_me 6 Very_much_like_me label values EQUALITY VALUES label values ALTRUSIM VALUES label values TRADITIONALISM VALUES label values RELIGIOUS rlgdgr label var RELIGIOUS "How religious are you?" label values SCAPITAL1 sclact label var SCAPITAL1 "Take part in social activities compared to others of same age" label values SCAPITAL2 brwmny label var SCAPITAL2 "Borrow money to make ends meet?" label var TUMEMBER "Trade Union Member?" label define TUM 1 Yes 0 No label values TUMEMBER TUM label values REFUGEE2 shrrfg label var REFUGEE2 "Country has more than its fair share of people applying refugee status" label var REFUGEE1 " Government should be generous judging applications for refugee status" label define REFUGEE1 1 Disagree_strongly 5 Agree_strongly label values REFUGEE1 REFUGEE1 label var eduattainXminority_area "eduattain * minority_area" label var schoolingXminority_area "schooling * minority_area" /* Labour Market Risk & Sample Delimiters */ label values mobility smbtjob label var mobility " Get a similar or better job with another employer" label var paidwork "Currently in paid work?" label values paidwork TUM label var UEMPLA "Currently unemployed actively looking for job" label values UEMPLA TUM label var RTRD "Currently retiered" label values RTRD TUM label var EDCTN "Currently in education" label values EDCTN TUM label var UEMPLI "Currently unemployed not activly looking for job" /* deletion of unnecessay vars */ drop ppltrst lrscale ginveco sclact rlgdgr brncntr eimrcnt eimpcnt imrcntr impcntr qfimwht imtcjob imbleco imbgeco imueclt imwbcrm acetalv pplstrd lwpeth imgfrnd shrrfg gvrfgap empl smbtjob gndr yrbrn brwmny edulvl eduyrs pdwrk edctn uempla uempli dsbld rtrd cmsrv hswrk dngoth mainact iscoco uemp12m uemp5yr mbtru hinctnt hincfel ipeqopt iphlppl imptrad regionat regionbe regionch regioncz regionde regiondk regiones regionfi regionfr regiongb regiongr regionhu regionie regionil regionit regionlu regionnl regionno regionpl regionpt regionse regionsi pweight dweight order name edition proddate cntry CNTRY CCODE REGINDICATOR DWEIGHT PWEIGHT PDWEIGHT iricheur1 ipooreur1 irichnoeur1 ipoornoeur1 iricheur_ordprobit ipooreur_ordprobit irichnoeur_ordprobit ipoornoeur_ordprobit eduattain schooling age age2 gender income perincome native immigrant_friends minority_area partisan_right isocode skill5 skill4 skill3 skill2 skill1 skill345 ELEMENTARY HIGHSCHOOL COLLEGE PHD racism crime antihate culture multiculti economy TRUST FREEMARKET EQUALITY ALTRUSIM TRADITIONALISM RELIGIOUS SCAPITAL1 SCAPITAL2 REFUGEE1 REFUGEE2 TUMEMBER eduattainXminority_area schoolingXminority_area mobility comp_a comp_d comp_nt s1 occupUE paidwork UEMPLA RTRD EDCTN UEMPLI save "ESSvol5recodedHH2004.dta", replace /* Dear Replicator: You have just recovered our ESS working dataset from */ /* the original ESSvol5 raw data. The file name of the recoded dataset */ /* is "ESSvol5recodedHH2004.dta" saved in your STATA working directory */ /* You can now run the other do.files to replicate our results */ /* These do files will use the recoded dataset automatically */