*--------------------------------------------------------------------------------------------------------------------------. * EU-Labour Force Survey - Data Service - German Microdata Lab * This routine converts EU-LFS 2003 AD HOC data formatted in CSV into DTA * Checked for the September 2017 release of the EU-LFS, as provided by Eurostat * The whole routine consists of two files: * Setup_EULFS_2003_ah.do * Labels_EULFS_1983-2016.do * Version 1 of this routine, September 2018 * Stata/MP 15.0 * (c) GESIS - Leibniz Institute for the Social Sciences * German Microdata Lab * Paul Notheisen, Klaus Pforr, Kathrin Stief * http://www.gesis.org/en/gml/ * Contact: gml@gesis.org * This Stata code is protected under the creative commons licence. *--------------------------------------------------------------------------------------------------------------------------. *------------------------------------------- Initialization commands ----------------------------------------------------. set more off clear * *--------------------------------------------------------------------------------------------------------------------------. * CONFIGURATION. * Specify file name stubs of the files you wish to be processed * (e.g. "at2003 be2003 bg2003 ch2003") local filestublist="" * Specify path where the csv files are stored * (e.g. "E:\data\EU-LFS\csv\"). local csv_data_path "" * Specify path where the file "Labels_EULFS_1983-2016.do" is stored * (e.g. E:\data\EU-LFS\syntax\Labels_EULFS_1983-2016.do). local label_syntax_path "" * Specify path where you want the dta (Stata format) files to be stored * (e.g. E:\data\EU-LFS\dta\). local stata_data_path "" * Specify name of final file (e.g. finalfile.dta) local finalfile "" *----- Loop over all files in stublist ------. foreach filestub in `filestublist' { *--- READ DATA ---. import delimited using "`="`csv_data_path'"+"`filestub'"+"_y.csv"'", clear delimiters(",") /* */ varnames(1) asdouble stripquotes(yes) /* */ stringcols(1 3 4 10 11 27 28 29 37 38 110 111 112 114 117 119 124) /* */ numericcols(2 5 6 7 8 9 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 30 31 32 33 34 35 36 39 40 /* */ 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 /* */ 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 /* */ 104 105 106 107 108 109 113 115 116 118 120 121 122 123 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140/* */ 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159) *--- Add Release-Variable --- gen release = "SEPT 2017" *----------------------------------------- Recode Alphanumeric Variables ---------------------------------------------------. * Variables which remain alphanumeric: hhnum, qhhnum, quarter, region, regionw, region1y. * country rename country country_ gen country=. foreach pair in ('AT'=1) ('BE'=2) ('BG'=3) ('CH'=4) ('CY'=5) ('CZ'=6) ('DE'=7) ('DK'=8) ('EE'=9) ('ES'=10) /* */ ('FI'=11) ('FR'=12) ('GR'=13) ('HR'=14) ('HU'=15) ('IE'=16) ('IS'=17) ('IT'=18) ('LT'=19) ('LU'=20) ('LV'=21) /* */ ('MT'=22) ('NL'=23) ('NO'=24) ('PL'=25) ('PT'=26) ('RO'=27) ('SE'=28) ('SI'=29) ('SK'=30) ('UK'=31) { replace country=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & country_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * region rename region region_ gen region=country_+region_ replace region="-5 No information delivered" if region_=="00" * national * For national, only first three characters are taken into account replace national=substr(national,1,3) rename national national_ gen national=. foreach pair in ('000'=0) ('001'=1) ('002'=2) ('003'=3) ('004'=4) ('005'=5) ('006'=6) /* */ ('007'=7) ('008'=8) ('009'=9) ('010'=10) ('011'=11) ('012'=12) ('013'=13) ('014'=14) /* */ ('015'=15) ('016'=16) ('017'=17) ('018'=18) ('019'=19) ('020'=20) ('021'=21) ('111'=111) /* */ ('800'=800) ('911'=911) ('999'=-1) "('NO '=-1)" "(' '=-1)" { replace national=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & national_==substr(regexs(1),2,length(regexs(1))-2) /* trim() removed due to 'NO '*/ } * yearesid rename yearesid yearesid_ gen yearesid=. foreach pair in ('0'=0) ('00'=0) ('01'=1) ('02'=2) ('03'=3) ('04'=4) ('05'=5) ('06'=6) ('07'=7) ('08'=8) ('09'=9) /* */ ('10'=10) ('11'=11) ('01-04'=2) ('05-10'=6) ('11-14'=12) ('15-19'=17) ('20-24'=22) ('25-29'=27) ('30-34'=32) ('35-39'=37) /* */ ('40-44'=42) ('45-49'=47) ('50-54'=52) ('50-99'=52) ('55-59'=57) ('60-64'=62) ('65-69'=67) ('70-74'=72) ('75-79'=77) ('80-84'=82) /* */ ('85-89'=87) ('90-94'=92) ('95-99'=97) ('75-99'=77) "(' '=-1)" ('01-Apr'=2) ('05-Oct'=6) ('Nov-14'=12) { replace yearesid=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & yearesid_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * countryb * For countryb, only first three characters are taken into account replace countryb=substr(countryb,1,3) rename countryb countryb_ gen countryb=. foreach pair in ('000'=0) ('001'=1) ('002'=2) ('003'=3) ('004'=4) ('005'=5) ('006'=6) /* */ ('007'=7) ('008'=8) ('009'=9) ('010'=10) ('011'=11) ('012'=12) ('013'=13) ('014'=14) /* */ ('015'=15) ('016'=16) ('017'=17) ('018'=18) ('019'=19) ('020'=20) ('021'=21) ('111'=111) /* */ ('800'=800) ('911'=911) ('999'=-2) "('NO '=-1)" "(' '=-1)" { replace countryb=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & countryb_==substr(regexs(1),2,length(regexs(1))-2) /* trim() removed due to 'NO '*/ } * countryw rename countryw countryw_ gen countryw=. foreach pair in ('AD'=01) ('AL'=02) ('AT'=03) ('BA'=04) ('BE'=05) ('BG'=06) ('BY'=07) /* */ ('CH'=08) ('CY'=09) ('CZ'=10) ('DE'=11) ('DK'=12) ('EE'=13) ('GR'=14) ('ES'=15) ('FI'=16) ('FO'=17) ('FR'=18) /* */ ('GG'=19) ('GI'=20) ('HR'=21) ('HU'=22) ('IE'=23) ('IM'=24) ('IS'=25) ('IT'=26) ('JE'=27) ('LI'=28) ('LT'=29) ('LU'=30) /* */ ('LV'=31) ('MC'=32) ('MD'=33) ('ME'=34) ('XM'=34) ('MK'=35) ('MT'=36) ('NL'=37) ('NO'=38) ('PL'=39) ('PT'=40) /* */ ('RO'=41) ('RS'=42) ('XS'=42) ('RU'=43) ('SE'=44) ('SI'=45) ('SK'=46) ('SM'=47) ('TR'=48) ('UA'=49) ('UK'=50) /* */ ('VA'=51) ('XK'=52) ('CS'=60) ('SU'=61) ('YU'=62) ('NN'=90) ('01'=110) ('02'=120) ('03'=130) ('04'=140) ('15'=150) /* */ ('05'=0500) ('DZ'=0501) ('EG'=0502) ('LY'=0503) ('MA'=0504) ('TN'=0505) ('06'=0600) ('AO'=0601) ('BF'=0602) /* */ ('BI'=0603) ('BJ'=0604) ('BW'=0605) ('CD'=0606) ('CF'=0607) ('CG'=0608) ('CI'=0609) ('CM'=0610) ('CV'=0611) /* */ ('DJ'=0612) ('ER'=0613) ('ET'=0614) ('GA'=0615) ('GH'=0616) ('GM'=0617) ('GN'=0618) ('GQ'=0619) ('GW'=0620) /* */ ('KE'=0621) ('KM'=0622) ('LR'=0623) ('LS'=0624) ('MG'=0625) ('ML'=0626) ('MR'=0627) ('MU'=0628) ('MW'=0629) /* */ ('MZ'=0630) ('NA'=0631) ('NE'=0632) ('NG'=0633) ('RW'=0634) ('SC'=0635) ('SD'=0636) ('SH'=0637) ('SL'=0638) /* */ ('SN'=0639) ('SO'=0640) ('SS'=0641) ('ST'=0642) ('SZ'=0643) ('TD'=0644) ('TG'=0645) ('TZ'=0646) ('UG'=0647) /* */ ('YT'=0648) ('ZA'=0649) ('ZM'=0650) ('ZW'=0651) ('07'=0700) ('BM'=0701) ('CA'=0702) ('GL'=0703) ('PM'=0704) /* */ ('US'=0705) ('08'=0800) ('AG'=0801) ('AI'=0802) ('AN'=0803) ('AW'=0804) ('BB'=0805) ('BL'=0806) ('BS'=0807) /* */ ('BZ'=0808) ('CR'=0809) ('CU'=0810) ('DM'=0811) ('DO'=0812) ('GD'=0813) ('GT'=0814) ('HN'=0815) ('HT'=0816) /* */ ('JM'=0817) ('KN'=0818) ('KY'=0819) ('LC'=0820) ('MF'=0821) ('MS'=0822) ('MX'=0823) ('NI'=0824) ('PA'=0825) /* */ ('PR'=0826) ('SV'=0827) ('TC'=0828) ('TT'=0829) ('VC'=0830) ('VG'=0831) ('09'=0900) ('AR'=0901) ('BO'=0902) /* */ ('BR'=0903) ('CL'=0904) ('CO'=0905) ('EC'=0906) ('FK'=0907) ('GY'=0908) ('PE'=0909) ('PY'=0910) ('SR'=0911) /* */ ('TF'=0912) ('UY'=0913) ('VE'=0914) ('10'=1000) ('CN'=1001) ('JP'=1002) ('KP'=1003) ('KR'=1004) ('MN'=1005) /* */ ('TW'=1006) ('11'=1100) ('AE'=1101) ('AM'=1102) ('AZ'=1103) ('BH'=1104) ('GE'=1105) ('IL'=1106) ('IQ'=1107) /* */ ('IR'=1108) ('JO'=1109) ('KG'=1110) ('KW'=1111) ('KZ'=1112) ('LB'=1113) ('OM'=1114) ('PS'=1115) ('QA'=1116) /* */ ('SA'=1117) ('SY'=1118) ('TJ'=1119) ('TM'=1120) ('UZ'=1121) ('YE'=1122) ('12'=1200) ('AF'=1201) ('BD'=1202) /* */ ('BN'=1203) ('BT'=1204) ('ID'=1205) ('IN'=1206) ('KH'=1207) ('LA'=1208) ('LK'=1209) ('MM'=1210) ('MV'=1211) /* */ ('MY'=1212) ('NP'=1213) ('PH'=1214) ('PK'=1215) ('SG'=1216) ('TH'=1217) ('TL'=1218) ('VN'=1219) ('13'=1300) /* */ ('AU'=1301) ('FJ'=1302) ('FM'=1303) ('KI'=1304) ('MH'=1305) ('NC'=1306) ('NR'=1307) ('NZ'=1308) ('PF'=1309) /* */ ('PG'=1310) ('PN'=1311) ('PW'=1312) ('SB'=1313) ('TO'=1314) ('TV'=1315) ('VU'=1316) ('WF'=1317) ('WS'=1318) /* */ ('14'=1400) ('005-EU27'=180) ('005-EU28'=180) ('008'=190) "('008-EUROPE OUTSIDE EU27'=190)" "('008-EUROPE OUTSIDE EU28'=190)" ('111'=160) ('911'=170) ('999'=-2) /* */ "('NO ANSWER'=-1)" "('NOT APPLICABLE'=-2)" "(' '=-1)" ('99'=-2) { replace countryw=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & countryw_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * EXCEPTIONS: MT, SI. foreach pair in ('000'=36) "('000 '=36)" "('000-OWN COUNTRY'=36)" { replace countryw=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & countryw_==trim(substr(regexs(1),2,length(regexs(1))-2)) & country_=="MT" } foreach pair in ('000'=45) "('000-OWN COUNTRY'=45)" { replace countryw=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & countryw_==trim(substr(regexs(1),2,length(regexs(1))-2)) & country_=="SI" } * regionw rename regionw regionw_ gen regionw=substr(countryw_,1,2)+regionw_ * separate coding of REGIONW for Slovenia (due to the separate coding of COUNTRYW in Slovenia). replace regionw="-1 No answer" if countryw_=="" replace regionw="-5 No information delivered" if regionw_=="00" replace regionw="-2 Not applicable" if regionw_=="99" replace regionw="-1 No answer" if regionw_=="" replace regionw="SI01" if countryw==45 & regionw_=="01" replace regionw="SI02" if countryw==45 & regionw_=="02" replace regionw="SI03" if countryw==45 & inlist(regionw_,"03","0003") replace regionw="SI04" if countryw==45 & inlist(regionw_,"04","0004") * na111y1d rename na111y1d na111y1d_ gen na111y1d=. foreach pair in ('A'=1) ('B'=2) ('C'=3) ('D'=4) ('E'=5) ('F'=6) ('G'=7) ('H'=8) ('I'=9) /* */ ('J'=10) ('K'=11) ('L'=12) ('M'=13) ('N'=14) ('O'=15) ('P'=16) ('Q'=17) "(' '=-1)" ('9'=-2) { replace na111y1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & na111y1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * countr1y rename countr1y countr1y_ gen countr1y=. foreach pair in ('AD'=01) ('AL'=02) ('AT'=03) ('BA'=04) ('BE'=05) ('BG'=06) ('BY'=07) ('CH'=08) ('CY'=09) /* */ ('CZ'=10) ('DE'=11) ('DK'=12) ('EE'=13) ('GR'=14) ('ES'=15) ('FI'=16) ('FO'=17) ('FR'=18) ('GG'=19) ('GI'=20) /* */ ('HR'=21) ('HU'=22) ('IE'=23) ('IM'=24) ('IS'=25) ('IT'=26) ('JE'=27) ('LI'=28) ('LT'=29) ('LU'=30) ('LV'=31) /* */ ('MC'=32) ('MD'=33) ('ME'=34) ('XM'=34) ('MK'=35) ('MT'=36) ('NL'=37) ('NO'=38) ('PL'=39) ('PT'=40) ('RO'=41) /* */ ('RS'=42) ('XS'=42) ('RU'=43) ('SE'=44) ('SI'=45) ('SK'=46) ('SM'=47) ('TR'=48) ('UA'=49) ('UK'=50) ('VA'=51) /* */ ('XK'=52) ('CS'=60) ('SU'=61) ('YU'=62) ('NN'=90) ('01'=110) ('02'=120) ('03'=130) ('04'=140) ('15'=150) ('05'=0500) /* */ ('DZ'=0501) ('EG'=0502) ('LY'=0503) ('MA'=0504) ('TN'=0505) ('06'=0600) ('AO'=0601) ('BF'=0602) ('BI'=0603) ('BJ'=0604) /* */ ('BW'=0605) ('CD'=0606) ('CF'=0607) ('CG'=0608) ('CI'=0609) ('CM'=0610) ('CV'=0611) ('DJ'=0612) ('ER'=0613) ('ET'=0614) /* */ ('GA'=0615) ('GH'=0616) ('GM'=0617) ('GN'=0618) ('GQ'=0619) ('GW'=0620) ('KE'=0621) ('KM'=0622) ('LR'=0623) ('LS'=0624) /* */ ('MG'=0625) ('ML'=0626) ('MR'=0627) ('MU'=0628) ('MW'=0629) ('MZ'=0630) ('NA'=0631) ('NE'=0632) ('NG'=0633) ('RW'=0634) /* */ ('SC'=0635) ('SD'=0636) ('SH'=0637) ('SL'=0638) ('SN'=0639) ('SO'=0640) ('SS'=0641) ('ST'=0642) ('SZ'=0643) ('TD'=0644) /* */ ('TG'=0645) ('TZ'=0646) ('UG'=0647) ('YT'=0648) ('ZA'=0649) ('ZM'=0650) ('ZW'=0651) ('07'=0700) ('BM'=0701) ('CA'=0702) /* */ ('GL'=0703) ('PM'=0704) ('US'=0705) ('08'=0800) ('AG'=0801) ('AI'=0802) ('AN'=0803) ('AW'=0804) ('BB'=0805) ('BL'=0806) /* */ ('BS'=0807) ('BZ'=0808) ('CR'=0809) ('CU'=0810) ('DM'=0811) ('DO'=0812) ('GD'=0813) ('GT'=0814) ('HN'=0815) ('HT'=0816) /* */ ('JM'=0817) ('KN'=0818) ('KY'=0819) ('LC'=0820) ('MF'=0821) ('MS'=0822) ('MX'=0823) ('NI'=0824) ('PA'=0825) ('PR'=0826) /* */ ('SV'=0827) ('TC'=0828) ('TT'=0829) ('VC'=0830) ('VG'=0831) ('09'=0900) ('AR'=0901) ('BO'=0902) ('BR'=0903) ('CL'=0904) /* */ ('CO'=0905) ('EC'=0906) ('FK'=0907) ('GY'=0908) ('PE'=0909) ('PY'=0910) ('SR'=0911) ('TF'=0912) ('UY'=0913) ('VE'=0914) /* */ ('10'=1000) ('CN'=1001) ('JP'=1002) ('KP'=1003) ('KR'=1004) ('MN'=1005) ('TW'=1006) ('11'=1100) ('AE'=1101) ('AM'=1102) /* */ ('AZ'=1103) ('BH'=1104) ('GE'=1105) ('IL'=1106) ('IQ'=1107) ('IR'=1108) ('JO'=1109) ('KG'=1110) ('KW'=1111) ('KZ'=1112) /* */ ('LB'=1113) ('OM'=1114) ('PS'=1115) ('QA'=1116) ('SA'=1117) ('SY'=1118) ('TJ'=1119) ('TM'=1120) ('UZ'=1121) ('YE'=1122) /* */ ('12'=1200) ('AF'=1201) ('BD'=1202) ('BN'=1203) ('BT'=1204) ('ID'=1205) ('IN'=1206) ('KH'=1207) ('LA'=1208) ('LK'=1209) /* */ ('MM'=1210) ('MV'=1211) ('MY'=1212) ('NP'=1213) ('PH'=1214) ('PK'=1215) ('SG'=1216) ('TH'=1217) ('TL'=1218) ('VN'=1219) /* */ ('13'=1300) ('AU'=1301) ('FJ'=1302) ('FM'=1303) ('KI'=1304) ('MH'=1305) ('NC'=1306) ('NR'=1307) ('NZ'=1308) ('PF'=1309) /* */ ('PG'=1310) ('PN'=1311) ('PW'=1312) ('SB'=1313) ('TO'=1314) ('TV'=1315) ('VU'=1316) ('WF'=1317) ('WS'=1318) /* */ ('14'=1400) "(' '=-1)" ('99'=-2) { replace countr1y=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & countr1y_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * region1y rename region1y region1y_ gen region1y=countr1y_+region1y_ replace region1y="-1 No answer" if countr1y_=="" replace region1y="-5 No information delivered" if region1y_=="00" replace region1y="-2 Not applicable" if region1y_=="99" replace region1y="-1 No answer" if region1y_=="" * na111d rename na111d na111d_ gen na111d=. foreach pair in ('A'=1) ('B'=2) ('C'=3) ('D'=4) ('E'=5) ('F'=6) ('G'=7) ('H'=8) ('I'=9) /* */ ('J'=10) ('K'=11) ('L'=12) ('M'=13) ('N'=14) ('O'=15) ('P'=16) ('Q'=17) "(' '=-1)" ('9'=-2) { replace na111d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & na111d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * na112j1d rename na112j1d na112j1d_ gen na112j1d=. foreach pair in ('A'=1) ('B'=2) ('C'=3) ('D'=4) ('E'=5) ('F'=6) ('G'=7) ('H'=8) ('I'=9) /* */ ('J'=10) ('K'=11) ('L'=12) ('M'=13) ('N'=14) ('O'=15) ('P'=16) ('Q'=17) "(' '=-1)" ('9'=-2) { replace na112j1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & na112j1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * na11pr1d rename na11pr1d na11pr1d_ gen na11pr1d=. foreach pair in ('A'=1) ('B'=2) ('C'=3) ('D'=4) ('E'=5) ('F'=6) ('G'=7) ('H'=8) ('I'=9) /* */ ('J'=10) ('K'=11) ('L'=12) ('M'=13) ('N'=14) ('O'=15) ('P'=16) ('Q'=17) "(' '=-1)" ('9'=-2) { replace na11pr1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & na11pr1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * hatlev1d rename hatlev1d hatlev1d_ gen hatlev1d=. foreach pair in ('L'=1) ('M'=2) ('H'=3) ('9'=-2) "(' '=-1)" { replace hatlev1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & hatlev1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } *--- Recode Missing Values --- recode marstat hhpriv (.=-1) recode leavclas (.=-9) recode hhinst proxy stapro supvisor wayjfoun ftpt ftptreas temp tempreas tempdur tempagcy shiftwk /* */ evenwk nightwk satwk sunwk wishmore waymore homewk lookoj lookreas exist2j stapro2j existpr stapropr /* */ seekreas seektype seekdur wantwork availble avaireas preseek needcare register mainstat educstat educlevl /* */ couratt courpurp courworh wstat1y stapro1y na11s na112js na11prs na111ys durune educ4wn lentr4w purp4w /* */ ahm2003_regstat ahm2003_reglevel ahm2003_csatt ahm2003_cspurpa ahm2003_cspurpb ahm2003_cspurpc ahm2003_csworha /* */ ahm2003_csworhb ahm2003_csworhc ahm2003_infself ahm2003_infcomp ahm2003_infbcast ahm2003_infvisit /* */ (.=-1) (9=-2) recode sizefirm mstartwk hwusual hwactual hwoverp hwoverpu hourreas hwwish /* */ hwactua2 monthpr leavreas hat97lev methfw hwustrai countryw /* */ (.=-1) (99=-2) recode iscopr3d educfild courlen courfild hatfield isco1d iscopr1d isco3d startime /* */ leavtime is881d is88pr3d is88pr1d is883d ahm2003_fieldhst ahm2003_regfield /* */ ahm2003_csfielda ahm2003_csfieldb ahm2003_csfieldc (.=-1) (999=-2) recode ystartwk yearpr hatyear ahm2003_cslena ahm2003_cslenb ahm2003_cslenc ahm2003_cslen (.=-1) (9999=-2) recode wstator signisal seekwork methoda methodb methodc methodd methode /* */ methodf methodg methodh methodi methodj methodk methodl methodm ilostat /* */ hhlink (9=-2) recode nowkreas hhspou hhfath hhmoth (99=-2) *--- Recode Variables in Countries which did not deliver any Information for this Variable foreach var in hhseqnum refyear refweek intweek degurba hhtype hhinst intwave intquest rem hhpriv /* */ hhlink hhspou hhfath hhmoth sex age marstat national yearesid countryb proxy wstator nowkreas stapro/* */ supvisor sizefirm countryw ystartwk mstartwk wayjfoun ftpt ftptreas temp tempreas tempdur /* */ tempagcy shiftwk evenwk nightwk satwk sunwk hwusual hwactual hwoverp hwoverpu hourreas wishmore /* */ waymore hwwish homewk lookoj lookreas exist2j stapro2j hwactua2 existpr yearpr monthpr leavreas /* */ stapropr iscopr3d seekwork seekreas seektype seekdur methoda methodb methodc methodd methode /* */ methodf methodg methodh methodi methodj methodk methodl methodm wantwork availble avaireas preseek /* */ needcare register mainstat educstat educlevl educfild couratt courlen courpurp courfild courworh /* */ hat97lev hatfield hatyear wstat1y stapro1y na111y1d countr1y ilostat na111d na11s isco1d na112j1d /* */ na112js na11pr1d na11prs iscopr1d durune educ4wn hatlev1d na111ys methfw lentr4w purp4w hwustrai isco3d /* */ startime leavtime leavclas region regionw region1y is881d is88pr3d is88pr1d is883d ahm2003_regstat /* */ ahm2003_reglevel ahm2003_csatt ahm2003_cspurpa ahm2003_cspurpb ahm2003_cspurpc ahm2003_csworha ahm2003_csworhb /* */ ahm2003_csworhc ahm2003_infself ahm2003_infcomp ahm2003_infbcast ahm2003_infvisit ahm2003_fieldhst /* */ ahm2003_regfield ahm2003_csfielda ahm2003_csfieldb ahm2003_csfieldc ahm2003_cslena ahm2003_cslenb /* */ ahm2003_cslenc ahm2003_cslen signisal { quietly count /* count cases in year and country of current loop run */ local nyc=r(N) if `nyc'>0 { /* only if there are cases in respective year and country */ if !inlist("`var'","educfild","courfild","hatfield","signisal") { /* for all variables except signisal, educfild, courfild, hatfield */ if substr("`:type `var''",1,3)=="str" { /* for string variables */ quietly count if inlist(`var',"","-1","-2","-3","-4","-5","-9") /* count negative and sysmis cases in respective variable in respective year and country */ } else { /* for numeric variables */ quietly count if `var'<0 | `var'==. /* count negative and sysmis cases in respective variable in respective year and country */ } } if "`var'"=="educfild" { /* for educfild */ quietly count if (`var'<0 | `var'==. | `var'==9) /* count negative, sysmis and 9 cases in educfild in respective year and country */ } if "`var'"=="courfild" { /* for courfild */ quietly count if (`var'<0 | `var'==. | `var'==9) /* count negative, sysmis and 9 cases in courfild in respective year and country */ } if "`var'"=="hatfield" { /* for hatfield */ quietly count if (`var'<0 | `var'==. | `var'==99) /* count negative, sysmis and 99 cases in hatfield in respective year and country */ } if "`var'"=="signisal" { /* for signisal */ quietly count if (`var'<0 | `var'==. | `var'==4) /* count negative, sysmis and 4 cases in signisal in respective year and country */ } if r(N)==`nyc' { /* number of theses cases = number all cases in year and country */ if substr("`:type `var''",1,3)=="str" { /* for string variables */ replace `var'="-3" /* replace to -3 */ } else { /* for numeric variables */ replace `var'=-3 /* replace to -3 */ } } } } *--- Recode or Rename Variabels in Specific Cases ---. * none *--- Declare User-Missing Values ---. recode hhseqnum refyear refweek intweek degurba hhtype hhinst intwave intquest rem hhpriv /* */ hhlink hhspou hhfath hhmoth sex age marstat national yearesid countryb proxy wstator nowkreas stapro /* */ supvisor sizefirm mstartwk countryw ystartwk wayjfoun ftpt ftptreas temp tempreas tempdur /* */ tempagcy shiftwk evenwk nightwk satwk sunwk hwusual hwactual hwoverp hwoverpu hourreas wishmore /* */ waymore hwwish homewk lookoj lookreas exist2j stapro2j hwactua2 existpr yearpr monthpr leavreas /* */ stapropr iscopr3d seekwork seekreas seektype seekdur methoda methodb methodc methodd methode /* */ methodf methodg methodh methodi methodj methodk methodl methodm wantwork availble avaireas preseek /* */ needcare register mainstat educstat educlevl educfild couratt courlen courpurp courfild courworh /* */ hat97lev hatfield hatyear wstat1y stapro1y na111y1d countr1y ilostat na111d na11s isco1d na112j1d /* */ na112js na11pr1d na11prs iscopr1d durune educ4wn hatlev1d na111ys methfw lentr4w purp4w hwustrai isco3d /* */ startime leavtime leavclas is881d is88pr3d is88pr1d is883d ahm2003_regstat ahm2003_reglevel ahm2003_csatt /* */ ahm2003_cspurpa ahm2003_cspurpb ahm2003_cspurpc ahm2003_csworha ahm2003_csworhb /* */ ahm2003_csworhc ahm2003_infself ahm2003_infcomp ahm2003_infbcast ahm2003_infvisit ahm2003_fieldhst /* */ ahm2003_regfield ahm2003_csfielda ahm2003_csfieldb ahm2003_csfieldc ahm2003_cslena ahm2003_cslenb /* */ ahm2003_cslenc ahm2003_cslen signisal /* */ (-1=.a) (-2=.b) (-3=.c) (-4=.d) (-5=.e) (-9=.i) * Delete tempvars and unnecessary original string variables. drop country_ region_ national_ countryb_ countryw_ regionw_ na111y1d_ countr1y_ region1y_ na111d_ na112j1d_ /* */ na11pr1d_ hatlev1d_ yearesid_ *--- Define Variable and Value Labels --- do `label_syntax_path' *--- Sort Variables ---. order qhhnum coeff quarter hhnum rec hhseqnum refyear refweek intweek country region degurba hhtype hhinst /* */ intwave intquest rem year hhpriv hhlink hhspou hhfath hhmoth sex age marstat national yearesid countryb /* */ proxy wstator nowkreas stapro signisal supvisor sizefirm countryw regionw ystartwk mstartwk wayjfoun /* */ ftpt ftptreas temp tempreas tempdur tempagcy shiftwk evenwk nightwk satwk sunwk hwusual hwactual hwoverp /* */ hwoverpu hourreas wishmore waymore hwwish homewk lookoj lookreas exist2j stapro2j hwactua2 existpr yearpr /* */ monthpr leavreas stapropr iscopr3d seekwork seekreas seektype seekdur methoda methodb methodc methodd /* */ methode methodf methodg methodh methodi methodj methodk methodl methodm wantwork availble avaireas preseek /* */ needcare register mainstat educstat educlevl educfild couratt courlen courpurp courfild courworh hat97lev /* */ hatfield hatyear wstat1y stapro1y na111y1d countr1y region1y ilostat na111d na11s isco1d na112j1d na112js /* */ na11pr1d na11prs iscopr1d durune educ4wn hatlev1d na111ys methfw lentr4w purp4w hwustrai isco3d startime /* */ leavtime leavclas ahm2003_fieldhst ahm2003_regstat ahm2003_reglevel ahm2003_regfield ahm2003_csatt /* */ ahm2003_cslena ahm2003_cslenb ahm2003_cslenc ahm2003_cspurpa ahm2003_cspurpb ahm2003_cspurpc ahm2003_csfielda /* */ ahm2003_csfieldb ahm2003_csfieldc ahm2003_csworha ahm2003_csworhb ahm2003_csworhc ahm2003_cslen ahm2003_infself /* */ ahm2003_infcomp ahm2003_infbcast ahm2003_infvisit is881d is88pr3d is88pr1d is883d release *--- Save file of current loop run. compress save `="`stata_data_path'"+"`filestub'"+"_ah.dta"', replace } *--- Compile and save Final File. local firstfile=1 foreach filestub in `filestublist' { if `firstfile'==1 { use `="`stata_data_path'"+"`filestub'"+"_ah.dta"', clear local firstfile=0 } else { append using `="`stata_data_path'"+"`filestub'"+"_ah.dta"' } } compress save `="`stata_data_path'"+"`finalfile'"', replace exit