*--------------------------------------------------------------------------------------------------------------------------. * EU-Labour Force Survey - Data Service - German Microdata Lab * This routine converts EU-LFS 2016 AD HOC data formatted in CSV into DTA * Checked for the June 2019 release of the EU-LFS, as provided by Eurostat * The whole routine consists of two files: * Setup_EULFS_2016_ah.do * Labels_EULFS_1983-2018.do * Version 1 of this routine, April 2020 * Stata/MP 15.0 * (c) GESIS - Leibniz Institute for the Social Sciences * German Microdata Lab * Klaus Pforr, Kathrin Stief, Peter Wieland * http://www.gesis.org/en/gml/ * Contact: gml@gesis.org * This Stata code is protected under the creative commons licence. * The coding standard for missing values is -1 "No response", -2 "Not applicable", * -3 "Not available", -4 "Not specified", -5 "No information provided", and * -9 "Otherwise" in exceptional cases (LEAVCLAS only). Optionally, missing values * in Stata can be encoded as the extended missing values .a, .b, .c, etc. by * reinserting the block “Declare User-Missing Values” at the end of this setup * (see "Explanatory notes on the recoding of missing values" in Readme). *--------------------------------------------------------------------------------------------------------------------------. *------------------------------------------- Initialization commands ----------------------------------------------------. set more off clear * *--------------------------------------------------------------------------------------------------------------------------. * CONFIGURATION. * Specify file name stubs of the files you wish to be processed * (e.g. "at2016 be2016 bg2016 ch2016") 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-2018.do" is stored * (e.g. "E:\data\EU-LFS\syntax\Labels_EULFS_1983-2018.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 2 5 6 7 13 14 17 18 34 35 41 42 66 74 75 83 101 136 137 139 140 152 153 176) /* */ numericcols(3 4 8 9 10 11 12 15 16 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 /* */ 36 37 38 39 40 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 /* */ 67 68 69 70 71 72 73 76 77 78 79 80 81 82 84 85 86 87 88 89 90 91 92 93 94 95 96 /* */ 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 138 141 142 143 144 /* */ 145 146 147 148 149 150 151 154 155 156 157 158 159 160 161 162 163 164 165 166 167 /* */ 168 169 170 171 172 173 174 175 177 178 179 180 181 182 183 184 185 186) *--- Add Release-Variable --- gen release = "JUN 2019" *----------------------------------------- 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 ('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) ('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) ('50-99'=52) ('75-99'=77) "(' '=-1)" { 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 '*/ } * nace1d rename nace1d nace1d_ gen nace1d=. 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) ('R'=18) ('S'=19) ('T'=20) ('U'=21) /* */ "(' '=-1)" ('9'=-2) { replace nace1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & nace1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * 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") * nacepr1d rename nacepr1d nacepr1d_ gen nacepr1d=. 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) ('R'=18) ('S'=19) ('T'=20) ('U'=21) "(' '=-1)" ('9'=-2) { replace nacepr1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & nacepr1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * nace2j1d rename nace2j1d nace2j1d_ gen nace2j1d=. 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) ('R'=18) ('S'=19) ('T'=20) ('U'=21) "(' '=-1)" ('9'=-2) { replace nace2j1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & nace2j1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * 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)) } * courlen rename courlen courlen_ gen courlen=. foreach pair in ('001'=1) ('002'=2) ('003'=3) ('004'=4) ('005'=5) ('006'=6) ('007'=7) ('008'=8) ('009'=9) ('010'=10) /* */ ('011'=11) ('012'=12) ('014'=14) ('015'=15) ('016'=16) ('017'=17) ('018'=18) ('020'=20) ('021'=21) ('022'=22) ('023'=23) /* */ ('024'=24) ('025'=25) ('026'=26) ('027'=27) ('028'=28) ('030'=30) ('032'=32) ('034'=34) ('035'=35) ('036'=36) ('038'=38) /* */ ('039'=39) ('040'=40) ('042'=42) ('043'=43) ('044'=44) ('045'=45) ('048'=48) ('050'=50) ('051'=51) ('052'=52) ('054'=54) /* */ ('055'=55) ('056'=56) ('058'=58) ('060'=60) ('062'=62) ('063'=63) ('064'=64) ('065'=65) ('068'=68) ('070'=70) ('072'=72) /* */ ('075'=75) ('076'=76) ('080'=80) ('084'=84) ('088'=88) ('090'=90) ('092'=92) ('096'=96) ('100'=100) ('120'=120) ('124'=124) /* */ ('126'=126) ('130'=130) ('140'=140) ('150'=150) ('152'=152) ('160'=160) ('2,0'=2) ('3,0'=3) ('999'=999) { replace courlen=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & courlen_==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)) } * nace1y1d rename nace1y1d nace1y1d_ gen nace1y1d=. 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) ('R'=18) ('S'=19) ('T'=20) ('U'=21) "(' '=-1)" ('9'=-2) { replace nace1y1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & nace1y1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * hatlfath rename hatlfath hatlfath_ gen hatlfath=. foreach pair in ('L'=1) ('M'=2) ('H'=3) ('9'=-2) ('8'=8) "(' '=-1)" { replace hatlfath=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & hatlfath_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * hatlmoth rename hatlmoth hatlmoth_ gen hatlmoth=. foreach pair in ('L'=1) ('M'=2) ('H'=3) ('9'=-2) ('8'=8) "(' '=-1)" { replace hatlmoth=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & hatlmoth_==trim(substr(regexs(1),2,length(regexs(1))-2)) } * ahm2016_addlev1d rename ahm2016_addlev1d ahm2016_addlev1d_ gen ahm2016_addlev1d=. foreach pair in ('L'=1) ('M'=2) ('H'=3) ('9'=-2) ('0'=0) "(' '=-1)" { replace ahm2016_addlev1d=real(substr(regexs(2),2,length(regexs(2))-2)) if /* */ regexm("`pair'","('.+')(=.+\))") & ahm2016_addlev1d_==trim(substr(regexs(1),2,length(regexs(1))-2)) } *--- Recode Missing Values --- recode marstat ageresid hhpriv eseg1d eseg2d (.=-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 hatvoc educvoc hatlfath hatlmoth ahm2016_workexp ahm2016_workstud /* */ ahm2016_dropreas ahm2016_nconreas ahm2016_support ahm2016_findmeth ahm2016_oklevel ahm2016_move4job ahm2016_cmt4job (.=-1) (9=-2) recode sizefirm mstartwk hwusual hwactual hwoverp hwoverpu hourreas hwwish hwactua2 monthpr leavreas hat97lev methfw hwustrai /* */ countryw incdecil ahm2016_addlevel ahm2016_mleavdat (.=-1) (99=-2) recode iscopr3d educfild courlen courfild hatfield isco1d iscopr1d isco3d startime leavtime is881d is88pr1d is883d /* */ is88pr3d hat11lev (.=-1) (999=-2) recode ystartwk yearpr hatyear ahm2016_yleavdat(.=-1) (9999=-2) recode ahm2016_leavdate (.=-1) (999999=-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 hhchildr hhwkstat hhpartnr hhparent hhpers (.=-4) (9=-2) recode hhage14 hhageyg hhnbpers hhnb0014 hhnbold hhnbchld hhnbch2 hhnbch5 hhnbch8 hhnbch11 hhnbch14 hhnbch17 /* */ hhnbch24 hhcomp hhnbempl hhnbunem hhnbinac hhnbwork (.=-4) (99=-2) *--- Recode Variables in Countries which did not deliver any Information for this Variable foreach var in hhseqnum sex national yearesid countryb proxy wstator nowkreas stapro nace1d /* */ na111d isco3d is883d countryw regionw ystartwk mstartwk ftpt temp tempdur hwusual hwactual hwoverp hwoverpu hourreas /* */ wishmore hwwish lookoj exist2j stapro2j nace2j1d na112j1d hwactua2 existpr yearpr monthpr stapropr nacepr1d na11pr1d /* */ iscopr3d is88pr3d seekwork seektype seekdur methoda methodb methodc methodd methode methodf methodg methodh methodi /* */ methodj methodk methodl methodm wantwork availble educstat educlevl couratt courlen hat97lev hat11lev hatvoc educvoc /* */ refyear refweek intweek country region degurba hhtype hhinst intwave intquest coeff year rem hhpriv age /* */ ageresid ilostat startime leavtime leavclas durune na11s isco1d is881d na112js na11prs iscopr1d is88pr1d educ4wn /* */ hatlev1d hhlink hhspou hhfath hhmoth marstat supvisor sizefirm wayjfoun ftptreas tempreas tempagcy shiftwk evenwk /* */ nightwk satwk sunwk waymore homewk lookreas leavreas seekreas avaireas preseek needcare register mainstat /* */ courpurp courworh hatyear wstat1y stapro1y nace1y1d na111y1d na111ys countr1y region1y incdecil eseg1d eseg2d /* */ hwustrai methfw purp4w lentr4w hhpers hhparent hhpartnr hhchildr hatlfath hatlmoth hhnbpers hhnb0014 hhnbold hhnbchld /* */ hhnbch2 hhnbch5 hhnbch8 hhnbch11 hhnbch14 hhnbch17 hhnbch24 hhageyg hhage14 hhcomp hhnbwork hhnbempl hhnbunem hhnbinac /* */ hhwkstat educfild courfild hatfield ahm2016_workexp ahm2016_workstud ahm2016_addlevel ahm2016_addlev1d ahm2016_dropreas /* */ ahm2016_yleavdat ahm2016_mleavdat ahm2016_leavdate ahm2016_nconreas ahm2016_support ahm2016_findmeth ahm2016_oklevel /* */ ahm2016_move4job ahm2016_cmt4job 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 these 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 Variables in Specific Cases ---. * none * Delete tempvars and unnecessary original string variables. drop country_ region_ national_ countryb_ countryw_ regionw_ na111y1d_ countr1y_ region1y_ na111d_ na112j1d_ /* */ na11pr1d_ hatlev1d_ nace2j1d_ nace1d_ nacepr1d_ nace1y1d_ yearesid_ courlen_ hatlfath_ hatlmoth_ ahm2016_addlev1d_ *--- Define Variable and Value Labels --- do `label_syntax_path' *--- Sort Variables ---. order release qhhnum hhnum hhseqnum sex national yearesid countryb proxy wstator nowkreas stapro signisal nace1d na111d isco3d is883d /* */ countryw regionw ystartwk mstartwk ftpt temp tempdur hwusual hwactual hwoverp hwoverpu hourreas wishmore hwwish lookoj /* */ exist2j stapro2j nace2j1d na112j1d hwactua2 existpr yearpr monthpr stapropr nacepr1d na11pr1d iscopr3d is88pr3d seekwork /* */ seektype seekdur methoda methodb methodc methodd methode methodf methodg methodh methodi methodj methodk methodl methodm /* */ wantwork availble educstat educlevl couratt courlen hat97lev hat11lev hatvoc educvoc refyear refweek intweek country region /* */ degurba hhtype hhinst intwave intquest coeff year quarter rem hhpriv age ageresid ilostat startime leavtime leavclas durune /* */ na11s isco1d is881d na112js na11prs iscopr1d is88pr1d educ4wn hatlev1d hhlink hhspou hhfath hhmoth marstat supvisor sizefirm /* */ wayjfoun ftptreas tempreas tempagcy shiftwk evenwk nightwk satwk sunwk waymore homewk lookreas leavreas seekreas avaireas /* */ preseek needcare register mainstat educfild courpurp courfild courworh hatfield hatyear wstat1y stapro1y nace1y1d na111y1d /* */ na111ys countr1y region1y incdecil eseg1d eseg2d hwustrai methfw purp4w lentr4w hhpers hhparent hhpartnr hhchildr hatlfath hatlmoth hhnbpers /* */ hhnb0014 hhnbold hhnbchld hhnbch2 hhnbch5 hhnbch8 hhnbch11 hhnbch14 hhnbch17 hhnbch24 hhageyg hhage14 hhcomp hhnbwork hhnbempl /* */ hhnbunem hhnbinac hhwkstat ahm2016_workexp ahm2016_workstud ahm2016_addlevel ahm2016_addlev1d ahm2016_dropreas ahm2016_yleavdat /* */ ahm2016_mleavdat ahm2016_leavdate ahm2016_nconreas ahm2016_support ahm2016_findmeth ahm2016_oklevel ahm2016_move4job ahm2016_cmt4job *--- Declare User-Missing Values ---. /*------------------------------------------------------------------------------------------------------------------------------* * Please delete the previous row, if you want to use the coding .a, .b, .c, etc. instead of -1, -2, -3, etc.. recode hhseqnum sex national yearesid countryb proxy wstator nowkreas stapro nace1d /* */ na111d isco3d is883d countryw ystartwk mstartwk ftpt temp tempdur hwusual hwactual hwoverp hwoverpu hourreas /* */ wishmore hwwish lookoj exist2j stapro2j nace2j1d na112j1d hwactua2 existpr yearpr monthpr stapropr nacepr1d na11pr1d /* */ iscopr3d is88pr3d seekwork seektype seekdur methoda methodb methodc methodd methode methodf methodg methodh methodi /* */ methodj methodk methodl methodm wantwork availble educstat educlevl couratt courlen hat97lev hat11lev hatvoc educvoc /* */ refyear refweek intweek country degurba hhtype hhinst intwave intquest coeff year rem hhpriv age /* */ ageresid ilostat startime leavtime leavclas durune na11s isco1d is881d na112js na11prs iscopr1d is88pr1d educ4wn /* */ hatlev1d hhlink hhspou hhfath hhmoth marstat supvisor sizefirm wayjfoun ftptreas tempreas tempagcy shiftwk evenwk /* */ nightwk satwk sunwk waymore homewk lookreas leavreas seekreas avaireas preseek needcare register mainstat educfild /* */ courpurp courfild courworh hatfield hatyear wstat1y stapro1y nace1y1d na111y1d na111ys countr1y incdecil eseg1d eseg2d/* */ hwustrai methfw purp4w lentr4w hhpers hhparent hhpartnr hhchildr hatlfath hatlmoth hhnbpers hhnb0014 hhnbold hhnbchld /* */ hhnbch2 hhnbch5 hhnbch8 hhnbch11 hhnbch14 hhnbch17 hhnbch24 hhageyg hhage14 hhcomp hhnbwork hhnbempl hhnbunem hhnbinac /* */ hhwkstat ahm2016_workexp ahm2016_workstud ahm2016_addlevel ahm2016_addlev1d ahm2016_dropreas ahm2016_yleavdat /* */ ahm2016_mleavdat ahm2016_leavdate ahm2016_nconreas ahm2016_support ahm2016_findmeth ahm2016_oklevel ahm2016_move4job /* */ ahm2016_cmt4job signisal (-1=.a) (-2=.b) (-3=.c) (-4=.d) (-5=.e) (-9=.i) *------------------------------------------------------------------------------------------------------------------------------*/ *--- 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