diff --git a/GLD/MEX/MEX_2005_ENOE/MEX_2005_ENOE_V02_M_V02_A_GLD/Programs/MEX_2005_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2005_ENOE/MEX_2005_ENOE_V02_M_V02_A_GLD/Programs/MEX_2005_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..30c6d0ef5 --- /dev/null +++ b/GLD/MEX/MEX_2005_ENOE/MEX_2005_ENOE_V02_M_V02_A_GLD/Programs/MEX_2005_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2145 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2005_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-15 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2005] +<_Data collection to_> [12/2005] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [] +<_Sample size (IND)_> [] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-13] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2005" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'05.dta" + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'05.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'05.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'05.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'05.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2005.dta", replace +*/ + +use "`path_in_stata'/ENOE_2005.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2005 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + * Code different in Q1,2 than Q3,4 for things after codes 305 + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire - 2005 all extended + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + *replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 1, 4) + replace hlp_whours_usual_bin = coe1_p5d /// if quarter == 1 + + gen hlp_whours_lw = . + *replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 1, 4) + replace hlp_whours_lw = coe1_p5c_thrs /// if quarter == 1 + + gen hlp_whours_nw = . + *replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 1, 4) + replace hlp_whours_nw = coe1_p5e_thrs /// if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify - 2005 all extended +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + *replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 1, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') /// & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire - 2005 is all extended + gen byte contract = . + replace contract = coe1_p3j + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire - 2005 is all extended + gen byte union = coe1_p3i + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic - 2005 is all extended + gen helper_fs = . + replace helper_fs = coe1_p3q + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> + gen byte firmsize_l_2 = . + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% COMPRESS_> + +compress + +* + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2006_ENOE/MEX_2006_ENOE_V02_M_V02_A_GLD/Programs/MEX_2006_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2006_ENOE/MEX_2006_ENOE_V02_M_V02_A_GLD/Programs/MEX_2006_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..7f49db2e1 --- /dev/null +++ b/GLD/MEX/MEX_2006_ENOE/MEX_2006_ENOE_V02_M_V02_A_GLD/Programs/MEX_2006_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2151 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2006_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-13 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2006] +<_Data collection to_> [12/2006] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [127,790] +<_Sample size (IND)_> [567,951] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-13] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2006" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'06.dta" + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'06.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear + +* Sepcial case, var cs_p14_c is double in Q3 +use "`path_in_stata'/sdemt306.dta" +tostring cs_p14_c, replace +gen quarter = 3 + +foreach quarter of numlist 1 2 4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'06.dta" + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'06.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'06.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2006.dta", replace +*/ + +use "`path_in_stata'/ENOE_2006.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2006 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + * Code different in Q1,2 than Q3,4 for things after codes 305 + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 3, 4) + replace hlp_whours_usual_bin = coe1_p5d if inrange(quarter, 1, 2) + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 3, 4) + replace hlp_whours_lw = coe1_p5c_thrs if inrange(quarter, 1, 2) + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 3, 4) + replace hlp_whours_nw = coe1_p5e_thrs if inrange(quarter, 1, 2) + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 3, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & inrange(quarter, 1, 2) + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inlist(quarter, 3, 4) + replace contract = coe1_p3j if inlist(quarter, 1, 2) + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if inlist(quarter, 1, 2) + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inlist(quarter, 3, 4) + replace helper_fs = coe1_p3q if inlist(quarter, 1, 2) + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> + gen byte firmsize_l_2 = . + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2007_ENOE/MEX_2007_ENOE_V02_M_V02_A_GLD/Programs/MEX_2007_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2007_ENOE/MEX_2007_ENOE_V02_M_V02_A_GLD/Programs/MEX_2007_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..b46e4d3a5 --- /dev/null +++ b/GLD/MEX/MEX_2007_ENOE/MEX_2007_ENOE_V02_M_V02_A_GLD/Programs/MEX_2007_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2179 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2007_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-13 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2007] +<_Data collection to_> [12/2007] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [127,566] +<_Sample size (IND)_> [561,652] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-13] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2007" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'07.dta" + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'07.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'07.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'07.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'07.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2007.dta", replace +*/ + +use "`path_in_stata'/ENOE_2007.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2007 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + * Code different in Q1,2 than Q3,4 for things after codes 305 + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inlist(quarter, 1, 3, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 2 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inlist(quarter, 1, 3, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 2 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inlist(quarter, 1, 3, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 2 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inlist(quarter, 1, 3, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 2 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inlist(quarter,1,3,4) + replace contract = coe1_p3j if quarter == 2 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 2 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inlist(quarter,1,3,4) + replace helper_fs = coe1_p3q if quarter == 2 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2008_ENOE/MEX_2008_ENOE_V02_M_V02_A_GLD/Programs/MEX_2008_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2008_ENOE/MEX_2008_ENOE_V02_M_V02_A_GLD/Programs/MEX_2008_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..bdee9d714 --- /dev/null +++ b/GLD/MEX/MEX_2008_ENOE/MEX_2008_ENOE_V02_M_V02_A_GLD/Programs/MEX_2008_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2177 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2008_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-13 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2008] +<_Data collection to_> [12/2008] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [126,719] +<_Sample size (IND)_> [555,179] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-13] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2008" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'08.dta" + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'08.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'08.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'08.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'08.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2008.dta", replace +*/ + +use "`path_in_stata'\ENOE_2008.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2008 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + * Code different in Q1,2 than Q3,4 for things after codes 305 + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inlist(quarter, 1, 3, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 2 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inlist(quarter, 1, 3, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 2 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inlist(quarter, 1, 3, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 2 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inlist(quarter, 1, 3, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 2 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inlist(quarter,1,3,4) + replace contract = coe1_p3j if quarter == 2 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 2 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inlist(quarter,1,3,4) + replace helper_fs = coe1_p3q if quarter == 2 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2009_ENOE/MEX_2009_ENOE_V02_M_V02_A_GLD/Programs/MEX_2009_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2009_ENOE/MEX_2009_ENOE_V02_M_V02_A_GLD/Programs/MEX_2009_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..3f30e22d4 --- /dev/null +++ b/GLD/MEX/MEX_2009_ENOE/MEX_2009_ENOE_V02_M_V02_A_GLD/Programs/MEX_2009_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2209 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2009_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-13 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2009] +<_Data collection to_> [12/2009] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [125,779] +<_Sample size (IND)_> [547,464] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-12] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2009" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'09.dta" + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'09.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + * For some reason, Q1 data is string, others numeric for some variables, change: + if `quarter' == 1 { + + use "`path_in_stata'/sdemt`quarter'09.dta" + cap gen quarter = `quarter' + destring est_d t_loc, replace + + } + else { + + quietly: append using "`path_in_stata'/sdemt`quarter'09.dta" + replace quarter = `quarter' if mi(quarter) + + } + + + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + * For some reason, Q1 data is string, others numeric for some variables, change: + if `quarter' == 1 { + + use "`path_in_stata'/hogt`quarter'09.dta" + destring est_d t_loc, replace + + } + else { + + quietly: append using "`path_in_stata'/hogt`quarter'09.dta" + + } +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + * For some reason, Q1 data is string, others numeric for some variables, change: + if `quarter' == 1 { + + use "`path_in_stata'/vivt`quarter'09.dta" + destring est_d t_loc, replace + + } + else { + + quietly: append using "`path_in_stata'/vivt`quarter'09.dta" + + } +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2009.dta", replace +*/ + +use "`path_in_stata'\ENOE_2009.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2009 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2010_ENOE/MEX_2010_ENOE_V02_M_V02_A_GLD/Programs/MEX_2010_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2010_ENOE/MEX_2010_ENOE_V02_M_V02_A_GLD/Programs/MEX_2010_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..d15af7652 --- /dev/null +++ b/GLD/MEX/MEX_2010_ENOE/MEX_2010_ENOE_V02_M_V02_A_GLD/Programs/MEX_2010_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2177 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2010_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-12 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2010] +<_Data collection to_> [12/2010] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [126,099] +<_Sample size (IND)_> [546,625] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-12] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2010" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'10.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'10.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'10.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'10.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'10.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2010.dta", replace +*/ + +use "`path_in_stata'\ENOE_2010.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2010 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2011_ENOE/MEX_2011_ENOE_V02_M_V02_A_GLD/Programs/MEX_2011_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2011_ENOE/MEX_2011_ENOE_V02_M_V02_A_GLD/Programs/MEX_2011_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..bdc81e41b --- /dev/null +++ b/GLD/MEX/MEX_2011_ENOE/MEX_2011_ENOE_V02_M_V02_A_GLD/Programs/MEX_2011_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2178 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2011_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-12 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2011] +<_Data collection to_> [12/2011] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [125,888] +<_Sample size (IND)_> [540,860] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO ] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-12] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2011" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'11.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'11.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'11.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'11.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'11.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the CMO to ISCO codes +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop cmo match + +*Merge in SCIAN 04 codes +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2011.dta", replace +*/ + +use "`path_in_stata'\ENOE_2011.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2011 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + * Domestic workers (codes 400), Guests (700s) and non-defined (999) are not counted + label var hsize "Household size" +* + + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + *label de lblmigrated_from_code + *label values migrated_from_code lblmigrated_from_code + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2012_ENOE/MEX_2012_ENOE_V02_M_V02_A_GLD/Programs/MEX_2012_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2012_ENOE/MEX_2012_ENOE_V02_M_V02_A_GLD/Programs/MEX_2012_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..a4e5e8c79 --- /dev/null +++ b/GLD/MEX/MEX_2012_ENOE/MEX_2012_ENOE_V02_M_V02_A_GLD/Programs/MEX_2012_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2243 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2012_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2012-12-11 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2012] +<_Data collection to_> [12/2012] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [125,785] +<_Sample size (IND)_> [536,626] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [CMO Q1, Q2, SINCO 2011 Q3, Q4] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2004 Q1, Q2, SCIAN 2007 Q3, Q4] +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-12] - [Update on arrangement process, isc, isic, njobs, hsize, ...] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2012" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce + +/* +* There is a change in questionnaire and classifiers. Please see INEGI website + +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe1t`quarter'12.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/coe2t`quarter'12.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/sdemt`quarter'12.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/hogt`quarter'12.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/vivt`quarter'12.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job (Q1 and Q2) - CMO USED +tostring coe1_p3, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_1_first_half +replace isco_1_first_half = "" if quarter > 2 +drop cmo match + +tostring coe2_p7a, gen(cmo) format("%04.0f") +merge m:1 cmo using "`path_in_stata'/CMO_09_ISCO_08.dta", keep(master match) nogen +rename isco isco_2_first_half +replace isco_2_first_half = "" if quarter > 2 +drop cmo match + +* Merge in the SINCO to ISCO codes - first and second job (Q3 and Q4) - SINCO 19 USED +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1_second_half +replace isco_1_second_half = "" if quarter < 3 +drop sinco match + +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2_second_half +replace isco_2_second_half = "" if quarter <3 +drop sinco match + +* Unite the halves +gen isco_1 = isco_1_first_half if inrange(quarter,1,2) +replace isco_1 = isco_1_second_half if inrange(quarter,3,4) + +gen isco_2 = isco_2_first_half if inrange(quarter,1,2) +replace isco_2 = isco_2_second_half if inrange(quarter,3,4) + +*Merge in SCIAN codes - first and second job - (Q 1&2 - SCIAN 04) +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_1_fh +replace isic_1_fh = "" if quarter > 2 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_04_ISIC_4.dta", keep(master match) nogen +rename isic isic_2_fh +replace isic_2_fh = "" if quarter > 2 +drop scian + +*Merge in SCIAN codes - first and second job - (Q 3&4 - SCIAN 07) +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1_sh +replace isic_1_sh = "" if quarter < 3 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2_sh +replace isic_2_sh = "" if quarter < 3 +drop scian + +* Unite the halves +gen isic_1 = isic_1_fh if inrange(quarter,1,2) +replace isic_1 = isic_1_sh if inrange(quarter,3,4) + +gen isic_2 = isic_2_fh if inrange(quarter,1,2) +replace isic_2 = isic_2_sh if inrange(quarter,3,4) + +* Save the file +save "`path_in_stata'/ENOE_2012.dta", replace +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOE_2012.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2012 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize_q34 = _N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + replace hsize_q34 = . if inrange(quarter, 3, 4) + bysort hhid quarter: gen hsize_q12 = _N if inrange(sdem_par, 101, 305) | inrange(sdem_par_c,501,623) + replace hsize_q12 = . if inrange(quarter, 1, 2) + gen hsize = hsize_q12 + replace hsize = hsize_q34 if missing(hsize) + drop hsize_* + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are not counted + * Codes different in Q1, Q2 + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + * Code different in Q1,2 than Q3,4 for things after codes 305 + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + + * Q3/Q4 + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) & inrange(quarter, 3, 4) + replace relationharm = 5 if inrange(sdem_par_c, 403, 424) & inrange(quarter, 3, 4) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) & inrange(quarter, 3, 4) + + * Q1/Q2 + replace relationharm = 4 if inrange(sdem_par_c, 601, 601) & inrange(quarter, 1, 2) + replace relationharm = 5 if inrange(sdem_par_c, 602, 623) & inrange(quarter, 1, 2) + replace relationharm = 6 if (inrange(sdem_par_c, 401, 461) | inrange(sdem_par_c, 701, 999) | inrange(sdem_par_c, 501, 503)) & inrange(quarter, 1, 2) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2013_ENOE/MEX_2013_ENOE_V02_M_V02_A_GLD/Programs/MEX_2013_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2013_ENOE/MEX_2013_ENOE_V02_M_V02_A_GLD/Programs/MEX_2013_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..9dd3037dd --- /dev/null +++ b/GLD/MEX/MEX_2013_ENOE/MEX_2013_ENOE_V02_M_V02_A_GLD/Programs/MEX_2013_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2190 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2013_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-05 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2013] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2013] +<_Data collection to_> [05/2013] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [179,964] +<_Sample size (IND)_> [689,476] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 2008] +<_OCCUP National_> [Sinco 11] +<_ISIC Version_> [Rev.4 ] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-D7] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-05] - [Update based on new info (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* All steps necessary to merge dataset + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2013" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'13.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'13.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'13.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'13.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'13.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2013.dta", replace +*/ + +use "`path_in_stata'\ENOE_2013.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2013 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year = industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2014_ENOE/MEX_2014_ENOE_V02_M_V02_A_GLD/Programs/MEX_2014_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2014_ENOE/MEX_2014_ENOE_V02_M_V02_A_GLD/Programs/MEX_2014_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..db6720a7a --- /dev/null +++ b/GLD/MEX/MEX_2014_ENOE/MEX_2014_ENOE_V02_M_V02_A_GLD/Programs/MEX_2014_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2187 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2014_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-05 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2014] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2014] +<_Data collection to_> [05/2014] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [126,803] +<_Sample size (IND)_> [540,117] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-01] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-02] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ +*----------1.1: Initial commands------------------------------* + + clear + set more off + set mem 800m + +*----------1.2: Set directories------------------------------* + + * Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2014" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'14.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'14.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'14.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'14.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'14.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2014.dta", replace +*/ + +use "`path_in_stata'\ENOE_2014.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2014 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + * + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year = . + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year = . + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year = . + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year = industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2015_ENOE/MEX_2015_ENOE_V02_M_V02_A_GLD/Programs/MEX_2015_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2015_ENOE/MEX_2015_ENOE_V02_M_V02_A_GLD/Programs/MEX_2015_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..f854e17e8 --- /dev/null +++ b/GLD/MEX/MEX_2015_ENOE/MEX_2015_ENOE_V02_M_V02_A_GLD/Programs/MEX_2015_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2184 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2015_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-03 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2015] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2015] +<_Data collection to_> [05/2015] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [126,994] +<_Sample size (IND)_> [536,347] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-03] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ +*----------1.1: Initial commands------------------------------* + + clear + set more off + set mem 800m + +*----------1.2: Set directories------------------------------* + + * Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2015" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'15.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'15.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'15.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'15.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'15.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2015.dta", replace +*/ + +use "`path_in_stata'\ENOE_2015.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2015 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + +} + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year = . if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year = . + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year = . + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year = . + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year = industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year = industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual =t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2016_ENOE/MEX_2016_ENOE_V02_M_V02_A_GLD/Programs/MEX_2016_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2016_ENOE/MEX_2016_ENOE_V02_M_V02_A_GLD/Programs/MEX_2016_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..da298a097 --- /dev/null +++ b/GLD/MEX/MEX_2016_ENOE/MEX_2016_ENOE_V02_M_V02_A_GLD/Programs/MEX_2016_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2182 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2016_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-03 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2016] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2016] +<_Data collection to_> [05/2016] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [127,383] +<_Sample size (IND)_> [530,636] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-03] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + + * Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2016" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'16.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'16.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'16.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'16.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'16.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2016.dta", replace +*/ + use "`path_in_stata'\ENOE_2016.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2016 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev_note> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = "9 - Distrito Federal" if subnatid1 == "9 - Ciudad de México" + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year = industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year = industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2017_ENOE/MEX_2017_ENOE_V02_M_V02_A_GLD/Programs/MEX_2017_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2017_ENOE/MEX_2017_ENOE_V02_M_V02_A_GLD/Programs/MEX_2017_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..67cd63216 --- /dev/null +++ b/GLD/MEX/MEX_2017_ENOE/MEX_2017_ENOE_V02_M_V02_A_GLD/Programs/MEX_2017_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2183 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2017_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA-18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-03 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2017] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2017] +<_Data collection to_> [05/2017] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [129,946] +<_Sample size (IND)_> [535,341] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-03] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2017" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per ca est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'17.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'17.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'17.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'17.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'17.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2017.dta", replace + +*/ + use "`path_in_stata'\ENOE_2017.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2017 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" + + *check int_Month out of the Q1 + tab int_month + +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2018_ENOE/MEX_2018_ENOE_V02_M_V02_A_GLD/Programs/MEX_2018_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2018_ENOE/MEX_2018_ENOE_V02_M_V02_A_GLD/Programs/MEX_2018_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..7e4d11651 --- /dev/null +++ b/GLD/MEX/MEX_2018_ENOE/MEX_2018_ENOE_V02_M_V02_A_GLD/Programs/MEX_2018_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2180 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2018_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> [STATA 18] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-02 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2018] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2018] +<_Data collection to_> [12/2018] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [129,176] +<_Sample size (IND)_> [529,533] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-02] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2018" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +* Rename variables for append all quarters +* harmonized output in a single file + +/* +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'18.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'18.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'18.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'18.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'18.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2018.dta", replace + +*/ + use "`path_in_stata'\ENOE_2018.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used" +* + + +*<_year_> + gen int year = 2018 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + +} + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Only one salary zone (border zone + * introduced Jan 2019) - https://www.banxico.org.mx/SieInternet/consultarDirectorioInternetAction.do?sector=10&accion=consultarCuadro&idCuadro=CL289&locale=es + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal' + replace salary_cat = 2 if wage_no_compen == `min_sal' + replace salary_cat = 3 if wage_no_compen > `min_sal' & wage_no_compen <= `min_sal'*2 + replace salary_cat = 4 if wage_no_compen > `min_sal'*2 & wage_no_compen <= `min_sal'*3 + replace salary_cat = 5 if wage_no_compen > `min_sal'*3 & wage_no_compen <= `min_sal'*5 + replace salary_cat = 6 if wage_no_compen > `min_sal'*5 & wage_no_compen <= `min_sal'*10 + replace salary_cat = 7 if wage_no_compen > `min_sal'*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = 1 + + tempfile wage_helper + save "`wage_helper'" + + restore + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + summ sdem_salario if sdem_zona == 1 + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == 1 & coe2_p6c == 2 + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year = . + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year = . + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year = . + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2019_ENOE/MEX_2019_ENOE_V02_M_V02_A_GLD/Programs/MEX_2019_ENOE_V02_M_V02_A_GLD_ALL.do b/GLD/MEX/MEX_2019_ENOE/MEX_2019_ENOE_V02_M_V02_A_GLD/Programs/MEX_2019_ENOE_V02_M_V02_A_GLD_ALL.do new file mode 100644 index 000000000..c3d69f96a --- /dev/null +++ b/GLD/MEX/MEX_2019_ENOE/MEX_2019_ENOE_V02_M_V02_A_GLD/Programs/MEX_2019_ENOE_V02_M_V02_A_GLD_ALL.do @@ -0,0 +1,2201 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2019_ENOE_V02_M_V02_A_GLD_ALL.do] +<_Application_> STATA 18 <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-12-02 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2019] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2019] +<_Data collection to_> [05/2019] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [134,545] +<_Sample size (IND)_> [547,309] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] + +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] +* Date: [2024-12-02] - [Update based on new series since 2020 (assembly, ISIC/ISCO, ...)] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2019" +local survey "ENOE" +local vermast "V02" +local veralt "V02" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +/* +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe1t`quarter'19.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/coe2t`quarter'19.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/sdemt`quarter'19.dta", clear + rename *, lower + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/hogt`quarter'19.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + use "`path_in_stata'/vivt`quarter'19.dta", clear + rename *, lower + cap tostring t_loc, replace force + tempfile d`quarter' + save "d`quarter'", replace + +} + +* Append files +clear +append using d1 d2 d3 d4 + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren per using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel per using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel per n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2019.dta", replace + +*/ + use "`path_in_stata'\ENOE_2019.dta", clear + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "isced_2011" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2019 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" + isid per hhid pid +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac, but at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys per : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen quarter = floor(per/100) + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + destring t_loc, replace + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + + * Name of Mexico's capital was changed in 2016 from Distrito Federal to + * Ciudad de Mexico. In the data (var ent) only from 2020. Correct here. + replace helper_lbl = "Ciudad de México" if helper_num == "9" + + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = . + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + +gen byte ed_mod_age = 5 +label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *cs_p13_1 (school level) & cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + label var potential_lf "Potential labour force status" +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* +} + + +*----------8.2: 7 day reference main job------------------------------* + +{ +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2020_ENOE/MEX_2020_ENOE_V03_M_V01_A_GLD/Programs/MEX_2020_ENOE_V03_M_V01_A_GLD_ALL.do b/GLD/MEX/MEX_2020_ENOE/MEX_2020_ENOE_V03_M_V01_A_GLD/Programs/MEX_2020_ENOE_V03_M_V01_A_GLD_ALL.do new file mode 100644 index 000000000..80e030f69 --- /dev/null +++ b/GLD/MEX/MEX_2020_ENOE/MEX_2020_ENOE_V03_M_V01_A_GLD/Programs/MEX_2020_ENOE_V03_M_V01_A_GLD_ALL.do @@ -0,0 +1,2147 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2020_ENOE_V03_M_V01_A_GLD_ALL.do] +<_Application_> [STATA] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2021-04-01 + +------------------------------------------------------------------------- + +<_Country_> Mexico (MEX) +<_Survey Title_> Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> 2020 +<_Study ID_> Microdata Library ID if present] +<_Data collection from_> 01/2020 +<_Data collection to_> 03/2020 +<_Source of dataset_> INEGI (Mexico NSO) +<_Sample size (HH)_> [] +<_Sample size (IND)_> 417,783 +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-18] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2019] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2024-10-24] - New master that only uses T1 of 2020 as the last ENOE before pandemic +* switch to ENOE-N + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2020" +local survey "ENOE" +local vermast "V03" +local veralt "V01" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +/* +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per" + +*** SDEM *** +use "`path_in_stata'/ENOE_SDEMT120.dta" + +* First rename all +rename * sdem_= + +* Now drop the cases we don't want + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Add quarter +gen quarter = 1 + +* Save tempfile +tempfile sdem +save "`sdem'" + +*** COE1 *** +use "`path_in_stata'/ENOE_COE1T120.dta" + +* First rename all +rename * coe1_= + +* Now drop the cases we don't want + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save tempfile +tempfile coe1 +save "`coe1'" + +*** COE2 *** +use "`path_in_stata'/ENOE_COE2T120.dta" + +* First rename all +rename * coe2_= + +* Now drop the cases we don't want + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save tempfile +tempfile coe2 +save "`coe2'" + +*** HOG *** +use "`path_in_stata'/ENOE_HOGT120.dta" + +* First rename all +rename * hog_= + +* Now drop the cases we don't want + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save tempfile +tempfile hog +save "`hog'" + +*** VIV *** +use "`path_in_stata'/ENOE_VIVT120.dta" + +* First rename all +rename * viv_= + +* Now drop the cases we don't want + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save tempfile +tempfile viv +save "`viv'" + +* Now merge it +use "`sdem'", clear + +* Add in COEs +quietly : merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren using "`coe1'", assert(match master) nogen +quietly : merge 1:1 cd_a ent con v_sel n_hog h_mud n_ren using "`coe2'", assert(match master) nogen + +* Add in HH level info, keep only HHs that have individual info +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel n_hog h_mud using "`hog'", keep(match) nogen +merge m:1 cd_a ent con v_sel using "`viv'", keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2020.dta", replace +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOE_2020.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str3 countrycode = "MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2020 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> +/* <_hhid_note> + + The variable should be a string made up of the elements to define it, that is psu code, ssu, ... + Each element should always be as long as needed for the longest element. That is, if there are + 60 psu coded 1 through 60, codes should be 01, 02, ..., 60. If there are 160 it should be 001, + 002, ..., 160. + + */ + + tostring (ent v_sel n_ren), gen(ent_str v_sel_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud), gen(n_hog_str h_mud_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" +* + + +*<_weight_> + +/* <_weight_note> + + In this case, we only have one quarter hence we will only keep weight as + quarterly weight, leave this missing. + + */ + + gen weight = . + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = . + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + gen strata = est_d + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + +} + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + replace urban=1 if inrange(t_loc,1,3) + replace urban=0 if t_loc==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire - 2020 ENOE only Q1 Extended + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + *replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d /// if quarter == 1 + + gen hlp_whours_lw = . + *replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs /// if quarter == 1 + + gen hlp_whours_nw = . + *replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs /// if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify - 2020 ENOE only Q1 Extended +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + *replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') /// & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + gen byte contract=coe1_p3j + recode contract 2=0 9=. + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + gen byte union = 1 if coe1_p3i == 1 + replace union = 0 if coe1_p3i == 2 + replace union = . if coe1_p3i == 9 + replace union = . if lstatus != 1 + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + gen byte firmsize_l = . + replace firmsize_l = 1 if coe1_p3q == 1 + replace firmsize_l = 2 if coe1_p3q == 2 + replace firmsize_l = 6 if coe1_p3q == 3 + replace firmsize_l = 11 if coe1_p3q == 4 + replace firmsize_l = 16 if coe1_p3q == 5 + replace firmsize_l = 21 if coe1_p3q == 6 + replace firmsize_l = 31 if coe1_p3q == 7 + replace firmsize_l = 51 if coe1_p3q == 8 + replace firmsize_l = 101 if coe1_p3q == 9 + replace firmsize_l = 251 if coe1_p3q == 10 + replace firmsize_l = 501 if coe1_p3q == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if coe1_p3q == 1 + replace firmsize_u = 5 if coe1_p3q == 2 + replace firmsize_u = 10 if coe1_p3q == 3 + replace firmsize_u = 15 if coe1_p3q == 4 + replace firmsize_u = 20 if coe1_p3q == 5 + replace firmsize_u = 30 if coe1_p3q == 6 + replace firmsize_u = 50 if coe1_p3q == 7 + replace firmsize_u = 100 if coe1_p3q == 8 + replace firmsize_u = 250 if coe1_p3q == 9 + replace firmsize_u = 500 if coe1_p3q==10 + replace firmsize_u = . if coe1_p3q==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup = 10 if occup == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> + * Only in extended survey. Since this has only Q1, OK to do + gen byte firmsize_l_2 = . + replace firmsize_l_2 = 1 if coe2_p7e == 1 + replace firmsize_l_2 = 2 if coe2_p7e == 2 + replace firmsize_l_2 = 6 if coe2_p7e == 3 + replace firmsize_l_2 = 11 if coe2_p7e == 4 + replace firmsize_l_2 = 16 if coe2_p7e == 5 + replace firmsize_l_2 = 21 if coe2_p7e == 6 + replace firmsize_l_2 = 31 if coe2_p7e == 7 + replace firmsize_l_2 = 51 if coe2_p7e == 8 + replace firmsize_l_2 = 101 if coe2_p7e == 9 + replace firmsize_l_2 = 251 if coe2_p7e == 10 + replace firmsize_l_2 = 501 if coe2_p7e == 11 + + * Add self-employed + replace firmsize_l_2 = 1 if empstat_2 == 4 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + + gen byte firmsize_u_2 = . + replace firmsize_u_2 = 1 if coe2_p7e == 1 + replace firmsize_u_2 = 5 if coe2_p7e == 2 + replace firmsize_u_2 = 10 if coe2_p7e == 3 + replace firmsize_u_2 = 15 if coe2_p7e == 4 + replace firmsize_u_2 = 20 if coe2_p7e == 5 + replace firmsize_u_2 = 30 if coe2_p7e == 6 + replace firmsize_u_2 = 50 if coe2_p7e == 7 + replace firmsize_u_2 = 100 if coe2_p7e == 8 + replace firmsize_u_2 = 250 if coe2_p7e == 9 + replace firmsize_u_2 = 500 if coe2_p7e == 10 + replace firmsize_u_2 = . if coe2_p7e == 11 + + * Add self-employed + replace firmsize_u_2 = 1 if empstat_2 == 4 + replace firmsize_u_2=. if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2020_ENOEN/MEX_2020_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2020_ENOEN_V01_M_V01_A_GLD_ALL.do b/GLD/MEX/MEX_2020_ENOEN/MEX_2020_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2020_ENOEN_V01_M_V01_A_GLD_ALL.do new file mode 100644 index 000000000..4955a948e --- /dev/null +++ b/GLD/MEX/MEX_2020_ENOEN/MEX_2020_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2020_ENOEN_V01_M_V01_A_GLD_ALL.do @@ -0,0 +1,2166 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2020_ENOEN_V01_M_V01_A_GLD_ALL.do] +<_Application_> [STATA] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2021-04-01 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2020] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2020] +<_Data collection to_> [05/2020] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [] +<_Sample size (IND)_> [] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-18] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2019] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007] +----------------------------------------------------------------------- +<_Version Control_> + +* Date: [2021-04-D1] - [Check code and input variables] +* Date: [2022-03-08] - [corrections variable wmonths, use of correct version for isic] +* Date: [2022-06-27] - [corrections variable empstat, firmsize] +* Date: [2022-09-07] - [corrections variable occup_skill, occup(2013-2020), subnatid1 , subnatid2 and occup_skill_2] +* Date: [2023-02-08] - [Correct empstat] +* Date: [2023-03-29] - [Correct subnatid1, educy] + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2020" +local survey "ENOEN" +local vermast "V01" +local veralt "V01" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce +/* +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 3/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE1T`quarter'20.dta" + +} + +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 3/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE2T`quarter'20.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 3/4 { + + quietly: append using "`path_in_stata'/ENOEN_SDEMT`quarter'20.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 3/4 { + + quietly: append using "`path_in_stata'/ENOEN_HOGT`quarter'20.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 3/4 { + + quietly: append using "`path_in_stata'/ENOEN_VIVT`quarter'20.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud n_ren using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud n_ren using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel tipo mes_cal ca using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOEN_2020.dta", replace +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOEN_2020.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode="MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOEN" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2020 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> +/* <_hhid_note> + + For ENOE-N years, we need the additional tipo (standard from now on) and mes_cal as well as + ca variables. According to CONEVAL in their ITPL calcualtions (*) ca is only necessary until + 2nd quarter 2021. We keep it nonetheless for consistency + + (*) - See codes in https://www.coneval.org.mx/Medicion/Paginas/ITLP-IS_pobreza_laboral.aspx + + */ + + tostring (ent v_sel mes_cal n_ren), gen(ent_str v_sel_str mes_cal_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud tipo ca), gen(n_hog_str h_mud_str tipo_str ca_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str tipo_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac_tri: at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys quarter : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac_tri*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = fac_men + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac_tri + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + * Data has estrato for trimester & month. + * Monthly has missing values, go for quarter + gen strata = est_d_tri + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + + +*<_type_of_interview_> + +/* <_type_of_interview_note> + + Since ENOE-N, there are two kinds of interviews: face to face and by + telephone. The latter can occur more than once in a quarter. Need it + to differentiate. + + */ + gen type_of_interview = tipo + label var type_of_interview "Type of interview (in person or telephone)" + la de lbltype 1 "Face to face" 2 "Telephone" + label values type_of_interview lbltype +* + +} + + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + replace urban=1 if inrange(t_loc_tri,1,3) + replace urban=0 if t_loc_tri==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 423) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = . + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = . + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = . + label de lblmigrated_binary 0 "No" 1 "Yes" + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + gen migrated_from_code = . + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = . + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = . + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire - ENOEN 2020 only basic Q3, 4 + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + *replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + *replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + *replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire - ENOEN 2020 only basic Q3, 4 +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + *replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + gen byte contract = coe1_p3i + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = . + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + gen byte firmsize_l = . + replace firmsize_l = 1 if coe1_p3l == 1 + replace firmsize_l = 2 if coe1_p3l == 2 + replace firmsize_l = 6 if coe1_p3l == 3 + replace firmsize_l = 11 if coe1_p3l == 4 + replace firmsize_l = 16 if coe1_p3l == 5 + replace firmsize_l = 21 if coe1_p3l == 6 + replace firmsize_l = 31 if coe1_p3l == 7 + replace firmsize_l = 51 if coe1_p3l == 8 + replace firmsize_l = 101 if coe1_p3l == 9 + replace firmsize_l = 251 if coe1_p3l == 10 + replace firmsize_l = 501 if coe1_p3l == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if coe1_p3l == 1 + replace firmsize_u = 5 if coe1_p3l == 2 + replace firmsize_u = 10 if coe1_p3l == 3 + replace firmsize_u = 15 if coe1_p3l == 4 + replace firmsize_u = 20 if coe1_p3l == 5 + replace firmsize_u = 30 if coe1_p3l == 6 + replace firmsize_u = 50 if coe1_p3l == 7 + replace firmsize_u = 100 if coe1_p3l == 8 + replace firmsize_u = 250 if coe1_p3l == 9 + replace firmsize_u = 500 if coe1_p3l==10 + replace firmsize_u = . if coe1_p3l==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup = 10 if occup == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> + * Only in extended survey. This version only has Q3, Q4, so skip + gen byte firmsize_l_2 = . + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2021_ENOEN/MEX_2021_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2021_ENOEN_V01_M_V01_A_GLD_ALL.do b/GLD/MEX/MEX_2021_ENOEN/MEX_2021_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2021_ENOEN_V01_M_V01_A_GLD_ALL.do new file mode 100644 index 000000000..9ff17f05a --- /dev/null +++ b/GLD/MEX/MEX_2021_ENOEN/MEX_2021_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2021_ENOEN_V01_M_V01_A_GLD_ALL.do @@ -0,0 +1,2304 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2021_ENOEN_V01_M_V01_A_GLD_ALL.do] +<_Application_> [STATA] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2021-04-01 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2021] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2021] +<_Data collection to_> [05/2021] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [157,660] +<_Sample size (IND)_> [609,843] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-13] +<_ISCED Version_> [] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [Sinco 2011 Q1, Q2, SINCO 2019 Q3, Q4] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2007 Q1, Q2, SCIAN 2018 Q3, Q4] +----------------------------------------------------------------------- +<_Version Control_> + + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2021" +local survey "ENOEN" +local vermast "V01" +local veralt "V01" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce + +/* +* There is a change in questionnaire and classifiers. Please see INEGI website + +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo ca mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE1T`quarter'21.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE2T`quarter'21.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_SDEMT`quarter'21.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_HOGT`quarter'21.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_VIVT`quarter'21.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud n_ren using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud n_ren using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel tipo mes_cal ca using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel tipo mes_cal ca n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - first and second job (Q1 and Q2) - SINCO 11 USED +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_1_first_half +replace isco_1_first_half = "" if quarter > 2 +drop sinco match + +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_11_ISCO_08.dta", keep(master match) nogen +rename isco isco_2_first_half +replace isco_2_first_half = "" if quarter > 2 +drop sinco match + +* Merge in the SINCO to ISCO codes - first and second job (Q3 and Q4) - SINCO 19 USED +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_1_second_half +replace isco_1_second_half = "" if quarter < 3 +drop sinco match + +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_2_second_half +replace isco_2_second_half = "" if quarter <3 +drop sinco match + +* Unite the halves +gen isco_1 = isco_1_first_half if inrange(quarter,1,2) +replace isco_1 = isco_1_second_half if inrange(quarter,3,4) + +gen isco_2 = isco_2_first_half if inrange(quarter,1,2) +replace isco_2 = isco_2_second_half if inrange(quarter,3,4) + +*Merge in SCIAN codes - first and second job - (Q 1&2 - SCIAN 07) +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_1_fh +replace isic_1_fh = "" if quarter > 2 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_07_ISIC_4.dta", keep(master match) nogen +rename isic isic_2_fh +replace isic_2_fh = "" if quarter > 2 +drop scian + +*Merge in SCIAN codes - first and second job - (Q 3&4 - SCIAN 18) +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_1_sh +replace isic_1_sh = "" if quarter < 3 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_2_sh +replace isic_2_sh = "" if quarter < 3 +drop scian + +* Unite the halves +gen isic_1 = isic_1_fh if inrange(quarter,1,2) +replace isic_1 = isic_1_sh if inrange(quarter,3,4) + +gen isic_2 = isic_2_fh if inrange(quarter,1,2) +replace isic_2 = isic_2_sh if inrange(quarter,3,4) + +* Save the file +save "`path_in_stata'/ENOEN_2021.dta", replace +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOEN_2021.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode="MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOEN" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2021 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> +/* <_hhid_note> + + For ENOE-N years, we need the additional tipo (standard from now on) and mes_cal as well as + ca variables. According to CONEVAL in their ITPL calcualtions (*) ca is only necessary until + 2nd quarter 2021. We keep it nonetheless for consistency + + (*) - See codes in https://www.coneval.org.mx/Medicion/Paginas/ITLP-IS_pobreza_laboral.aspx + + */ + + tostring (ent v_sel mes_cal n_ren), gen(ent_str v_sel_str mes_cal_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud tipo ca), gen(n_hog_str h_mud_str tipo_str ca_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str tipo_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac_tri: at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys quarter : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac_tri*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = fac_men + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac_tri + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + * Data has estrato for trimester & month. + * Monthly has missing values, go for quarter + gen strata = est_d_tri + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + + +*<_type_of_interview_> + +/* <_type_of_interview_note> + + Since ENOE-N, there are two kinds of interviews: face to face and by + telephone. The latter can occur more than once in a quarter. Need it + to differentiate. + + */ + gen type_of_interview = tipo + label var type_of_interview "Type of interview (in person or telephone)" + la de lbltype 1 "Face to face" 2 "Telephone" + label values type_of_interview lbltype +* + +} + + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + replace urban=1 if inrange(t_loc_tri,1,3) + replace urban=0 if t_loc_tri==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 424) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = 1 + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = 1 + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = 0 + * Migrated if either in different country or state (20a) or a different municipality (20b) + replace migrated_binary = 1 if inrange(sdem_cs_p20a_1,2,4) | sdem_cs_p20b_1 == 2 + label de lblmigrated_binary 0 "No" 1 "Yes", replace + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + replace migrated_from_cat = 3 if sdem_cs_p20a_1 == 1 & sdem_cs_p20b_1 == 2 + replace migrated_from_cat = 4 if sdem_cs_p20a_1 == 2 + replace migrated_from_cat = 5 if inrange(sdem_cs_p20a_1,3,4) + replace migrated_from_cat = . if migrated_binary == 1 + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + * We want to code this as subnatid1, use that info to merge it in + gen mig_code_helper = sdem_cs_p20a_c if sdem_cs_p20a_c < 100 & migrated_binary == 1 + preserve + + keep subnatid1 + rename subnatid1 long_name + gen counter = 1 + collapse (rawsum) counter, by(long_name) + drop counter + gen mig_code_helper = substr(long_name,1,2) + destring mig_code_helper, replace + tempfile mig_helper + save "`mig_helper'" + + restore + + merge m:1 mig_code_helper using "`mig_helper'", assert(match master) nogen + + gen migrated_from_code = long_name + drop long_name mig_code_helper + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = "" + replace migrated_from_country = "ZAF" if sdem_cs_p20a_c == 154 + replace migrated_from_country = "ARG" if sdem_cs_p20a_c == 204 + replace migrated_from_country = "BLZ" if sdem_cs_p20a_c == 208 + replace migrated_from_country = "BRA" if sdem_cs_p20a_c == 211 + replace migrated_from_country = "CAN" if sdem_cs_p20a_c == 213 + replace migrated_from_country = "COL" if sdem_cs_p20a_c == 214 + replace migrated_from_country = "CRI" if sdem_cs_p20a_c == 215 + replace migrated_from_country = "CUB" if sdem_cs_p20a_c == 216 + replace migrated_from_country = "CHL" if sdem_cs_p20a_c == 217 + replace migrated_from_country = "ECU" if sdem_cs_p20a_c == 219 + replace migrated_from_country = "SLV" if sdem_cs_p20a_c == 220 + replace migrated_from_country = "USA" if sdem_cs_p20a_c == 221 + replace migrated_from_country = "GTM" if sdem_cs_p20a_c == 225 + replace migrated_from_country = "HTI" if sdem_cs_p20a_c == 228 + replace migrated_from_country = "HND" if sdem_cs_p20a_c == 229 + replace migrated_from_country = "NIC" if sdem_cs_p20a_c == 234 + replace migrated_from_country = "PAN" if sdem_cs_p20a_c == 235 + replace migrated_from_country = "PRY" if sdem_cs_p20a_c == 236 + replace migrated_from_country = "PRI" if sdem_cs_p20a_c == 238 + replace migrated_from_country = "DOM" if sdem_cs_p20a_c == 239 + replace migrated_from_country = "URY" if sdem_cs_p20a_c == 247 + replace migrated_from_country = "VEN" if sdem_cs_p20a_c == 250 + replace migrated_from_country = "IND" if sdem_cs_p20a_c == 325 + replace migrated_from_country = "DEU" if sdem_cs_p20a_c == 402 + replace migrated_from_country = "ESP" if sdem_cs_p20a_c == 415 + replace migrated_from_country = "FRA" if sdem_cs_p20a_c == 419 + replace migrated_from_country = "ITA" if sdem_cs_p20a_c == 425 + replace migrated_from_country = "GBR" if sdem_cs_p20a_c == 439 + replace migrated_from_country = "AUS" if sdem_cs_p20a_c == 501 + + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = sdem_cs_p20c_1 + recode migrated_reason (3 4 = 1) (5 = 2) (1 2 = 3) (6 7 9 = 4) (8 10 11 = 5) + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2022_ENOEN/MEX_2022_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2022_ENOEN_V01_M_V01_A_GLD_ALL.do b/GLD/MEX/MEX_2022_ENOEN/MEX_2022_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2022_ENOEN_V01_M_V01_A_GLD_ALL.do new file mode 100644 index 000000000..bdabf841b --- /dev/null +++ b/GLD/MEX/MEX_2022_ENOEN/MEX_2022_ENOEN_V01_M_V01_A_GLD/Programs/MEX_2022_ENOEN_V01_M_V01_A_GLD_ALL.do @@ -0,0 +1,2267 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2022_ENOEN_V01_M_V01_A_GLD_ALL.do] +<_Application_> [STATA] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2022-04-01 + +------------------------------------------------------------------------- + +<_Country_> [Mexico (MEX)] +<_Survey Title_> [Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> [2022] +<_Study ID_> [Microdata Library ID if present] +<_Data collection from_> [01/2022] +<_Data collection to_> [12/2022] +<_Source of dataset_> [Mexico NSO] +<_Sample size (HH)_> [] +<_Sample size (IND)_> [] +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-18] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [INCO 2019] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2018] +----------------------------------------------------------------------- +<_Version Control_> + + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2022" +local survey "ENOEN" +local vermast "V01" +local veralt "V01" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce + +/* +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. This is because some repeat: there are p1 in one file, +* p1 in another, Stata will keep the master, not tell us about the repeat. +* We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE1T`quarter'22.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_COE2T`quarter'22.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_SDEMT`quarter'22.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_HOGT`quarter'22.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOEN_VIVT`quarter'22.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud n_ren using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud n_ren using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel tipo mes_cal using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - SINCO 19 USED +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match + +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOEN_2022.dta", replace +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOEN_2022.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode="MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOEN" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2022 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> +/* <_hhid_note> + + For ENOE-N years, we need the additional tipo (standard from now on) and mes_cal as well as + ca variables. According to CONEVAL in their ITPL calcualtions (*) ca is only necessary until + 2nd quarter 2021. We keep it nonetheless for consistency + + (*) - See codes in https://www.coneval.org.mx/Medicion/Paginas/ITLP-IS_pobreza_laboral.aspx + + */ + + tostring (ent v_sel mes_cal n_ren), gen(ent_str v_sel_str mes_cal_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud tipo), gen(n_hog_str h_mud_str tipo_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str tipo_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac_tri: at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys quarter : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac_tri*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = fac_men + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac_tri + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + * Data has estrato for trimester & month. + * Monthly has missing values, go for quarter + gen strata = est_d_tri + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + + +*<_type_of_interview_> + +/* <_type_of_interview_note> + + Since ENOE-N, there are two kinds of interviews: face to face and by + telephone. The latter can occur more than once in a quarter. Need it + to differentiate. + + */ + gen type_of_interview = tipo + label var type_of_interview "Type of interview (in person or telephone)" + la de lbltype 1 "Face to face" 2 "Telephone" + label values type_of_interview lbltype +* + +} + + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + replace urban=1 if inrange(t_loc_tri,1,3) + replace urban=0 if t_loc_tri==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 6 "37 - Torreón" 20 "38 - Ciudad Juárez" 30 "39 - Coatzacoalcos" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 424) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = 1 + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = 1 + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = 0 + * Migrated if either in different country or state (20a) or a different municipality (20b) + replace migrated_binary = 1 if inrange(sdem_cs_p20a_1,2,4) | sdem_cs_p20b_1 == 2 + label de lblmigrated_binary 0 "No" 1 "Yes", replace + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + replace migrated_from_cat = 3 if sdem_cs_p20a_1 == 1 & sdem_cs_p20b_1 == 2 + replace migrated_from_cat = 4 if sdem_cs_p20a_1 == 2 + replace migrated_from_cat = 5 if inrange(sdem_cs_p20a_1,3,4) + replace migrated_from_cat = . if migrated_binary == 1 + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + * We want to code this as subnatid1, use that info to merge it in + gen mig_code_helper = sdem_cs_p20a_c if sdem_cs_p20a_c < 100 & migrated_binary == 1 + preserve + + keep subnatid1 + rename subnatid1 long_name + gen counter = 1 + collapse (rawsum) counter, by(long_name) + drop counter + gen mig_code_helper = substr(long_name,1,2) + destring mig_code_helper, replace + tempfile mig_helper + save "`mig_helper'" + + restore + + merge m:1 mig_code_helper using "`mig_helper'", assert(match master) nogen + + gen migrated_from_code = long_name + drop long_name mig_code_helper + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = "" + replace migrated_from_country = "ARG" if sdem_cs_p20a_c == 204 + replace migrated_from_country = "BLZ" if sdem_cs_p20a_c == 208 + replace migrated_from_country = "BOL" if sdem_cs_p20a_c == 210 + replace migrated_from_country = "BRA" if sdem_cs_p20a_c == 211 + replace migrated_from_country = "CAN" if sdem_cs_p20a_c == 213 + replace migrated_from_country = "COL" if sdem_cs_p20a_c == 214 + replace migrated_from_country = "CRI" if sdem_cs_p20a_c == 215 + replace migrated_from_country = "CUB" if sdem_cs_p20a_c == 216 + replace migrated_from_country = "CHL" if sdem_cs_p20a_c == 217 + replace migrated_from_country = "ECU" if sdem_cs_p20a_c == 219 + replace migrated_from_country = "SLV" if sdem_cs_p20a_c == 220 + replace migrated_from_country = "USA" if sdem_cs_p20a_c == 221 + replace migrated_from_country = "GTM" if sdem_cs_p20a_c == 225 + replace migrated_from_country = "HTI" if sdem_cs_p20a_c == 228 + replace migrated_from_country = "HND" if sdem_cs_p20a_c == 229 + replace migrated_from_country = "NIC" if sdem_cs_p20a_c == 234 + replace migrated_from_country = "PAN" if sdem_cs_p20a_c == 235 + replace migrated_from_country = "DOM" if sdem_cs_p20a_c == 239 + replace migrated_from_country = "URY" if sdem_cs_p20a_c == 247 + replace migrated_from_country = "VEN" if sdem_cs_p20a_c == 250 + replace migrated_from_country = "SAU" if sdem_cs_p20a_c == 302 + replace migrated_from_country = "KOR" if sdem_cs_p20a_c == 313 + replace migrated_from_country = "CHN" if sdem_cs_p20a_c == 315 + replace migrated_from_country = "UAE" if sdem_cs_p20a_c == 321 + replace migrated_from_country = "IND" if sdem_cs_p20a_c == 325 + replace migrated_from_country = "JPN" if sdem_cs_p20a_c == 330 + replace migrated_from_country = "LBN" if sdem_cs_p20a_c == 335 + replace migrated_from_country = "DEU" if sdem_cs_p20a_c == 402 + replace migrated_from_country = "ESP" if sdem_cs_p20a_c == 415 + replace migrated_from_country = "FRA" if sdem_cs_p20a_c == 419 + replace migrated_from_country = "IRL" if sdem_cs_p20a_c == 423 + replace migrated_from_country = "ITA" if sdem_cs_p20a_c == 425 + replace migrated_from_country = "NLD" if sdem_cs_p20a_c == 436 + replace migrated_from_country = "POR" if sdem_cs_p20a_c == 438 + replace migrated_from_country = "GBR" if sdem_cs_p20a_c == 439 + replace migrated_from_country = "AUS" if sdem_cs_p20a_c == 501 + + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = sdem_cs_p20c_1 + recode migrated_reason (3 4 = 1) (5 = 2) (1 2 = 3) (6 7 9 = 4) (8 10 11 = 5) + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic = "" if lstatus != 1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/GLD/MEX/MEX_2023_ENOE/MEX_2023_ENOE_V01_M_V01_A_GLD/Programs/MEX_2023_ENOE_V01_M_V01_A_GLD_ALL.do b/GLD/MEX/MEX_2023_ENOE/MEX_2023_ENOE_V01_M_V01_A_GLD/Programs/MEX_2023_ENOE_V01_M_V01_A_GLD_ALL.do new file mode 100644 index 000000000..f9b7ceb82 --- /dev/null +++ b/GLD/MEX/MEX_2023_ENOE/MEX_2023_ENOE_V01_M_V01_A_GLD/Programs/MEX_2023_ENOE_V01_M_V01_A_GLD_ALL.do @@ -0,0 +1,2269 @@ + +/*%%============================================================================================= + 0: GLD Harmonization Preamble +==============================================================================================%%*/ + +/* ----------------------------------------------------------------------- + +<_Program name_> [MEX_2023_ENOE_V01_M_V01_A_GLD_ALL.do] +<_Application_> [STATA] <_Application_> +<_Author(s)_> [The World Bank Jobs Group] +<_Date created_> 2024-10-29 + +------------------------------------------------------------------------- + +<_Country_> Mexico (MEX) +<_Survey Title_> Encuesta Nacional de Ocupación y Empleo] +<_Survey Year_> 2020 +<_Study ID_> Microdata Library ID if present] +<_Data collection from_> 01/2023 +<_Data collection to_> 12/2023 +<_Source of dataset_> INEGI (Mexico NSO) +<_Sample size (HH)_> +<_Sample size (IND)_> +<_Sampling method_> [ El tipo de muestreo utilizado es probabilístico, bietápico, estratificado y por conglomerados.] +<_Geographic coverage_> [Los niveles geograficos usados en la encuesta de México comienzan en estados siguen con ciudades autorrepresentadas y terminan con municipios de las ciudades autorrepresentadas. https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/metodologias/est/cobertura.pdf] +<_Currency_> [Pesos] + +----------------------------------------------------------------------- + +<_ICLS Version_> [ICLS-18] +<_ISCED Version_> [ISCED 2011] +<_ISCO Version_> [ISCO 08] +<_OCCUP National_> [SINCO 2019] +<_ISIC Version_> [Rev.4] +<_INDUS National_> [SCIAN 2018] +----------------------------------------------------------------------- +<_Version Control_> + +* + + + +-------------------------------------------------------------------------*/ + + +/*%%============================================================================================= + 1: Setting up of program environment, dataset +==============================================================================================%%*/ + +*----------1.1: Initial commands------------------------------* + +clear +set more off +set mem 800m + +*----------1.2: Set directories------------------------------* + +* Define path sections +local server "Y:/GLD-Harmonization/529026_MG/Countries" +local country "MEX" +local year "2023" +local survey "ENOE" +local vermast "V01" +local veralt "V01" + +* From the definitions, set path chunks +local level_1 "`country'_`year'_`survey'" +local level_2_mast "`level_1'_`vermast'_M" +local level_2_harm "`level_1'_`vermast'_M_`veralt'_A_GLD" + +* From chunks, define path_in, path_output folder +local path_in_stata "`server'/`country'/`level_1'/`level_2_mast'/Data/Stata" +local path_in_other "`server'/`country'/`level_1'/`level_2_mast'/Data/Original" +local path_output "`server'/`country'/`level_1'/`level_2_harm'/Data/Harmonized" + +* Define Output file name +local out_file "`level_2_harm'_ALL.dta" + +*----------1.3: Database assembly------------------------------* + +* All steps necessary to merge datasets (if several) to have all elements needed to produce + +/* +* We want all variables to have the prefix of its source but for the variables +* that we use for merging. We create a local with the ones we exclude +local exclude "cd_a ent con v_sel n_hog h_mud n_ren loc t_loc t_loc_tri t_loc_men fac fac_tri fac_men mun est est_d ageb ur n_ent r_def upm n_pro_viv per tipo mes_cal quarter est_d_tri est_d_men" + +*** COE1 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOE_COE1T`quarter'23.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} +* First rename all +rename * coe1_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe1_`var' + + * If present, rename + if _rc == 0 { + + rename coe1_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe1 +save "`coe1'" + + +*** COE2 *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOE_COE2T`quarter'23.dta" + +} + +* First rename all +rename * coe2_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des coe2_`var' + + * If present, rename + if _rc == 0 { + + rename coe2_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile coe2 +save "`coe2'" + + +*** SDEM *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOE_SDEMT`quarter'23.dta" + cap gen quarter = `quarter' + replace quarter = `quarter' if mi(quarter) + +} + +* First rename all +rename * sdem_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des sdem_`var' + + * If present, rename + if _rc == 0 { + + rename sdem_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile sdem +save "`sdem'" + + +*** HOG *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOE_HOGT`quarter'23.dta" + +} + +* First rename all +rename * hog_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des hog_`var' + + * If present, rename + if _rc == 0 { + + rename hog_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile hog +save "`hog'" + + +*** VIV *** +clear +forvalues quarter = 1/4 { + + quietly: append using "`path_in_stata'/ENOE_VIVT`quarter'23.dta" + +} + +* First rename all +rename * viv_= + +* Add prefix to all but the merging variables +foreach var of local exclude { + + * Check if variable in data + cap des viv_`var' + + * If present, rename + if _rc == 0 { + + rename viv_`var' `var' + + } // end if variable present +} // end loop through variable list + +* Save as tempfile +tempfile viv +save "`viv'" + + +*** Merge *** + +* Start with Individual level data +use "`sdem'", clear + +merge 1:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud n_ren using "`coe1'", assert(match master) nogen +merge 1:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud n_ren using "`coe2'", assert(match master) nogen + +* Add household level, keeping only the households that match the HHs with individual data +* Should not lose any, thus check the number of rows is the same before and after +count +local num_rows = `r(N)' + +merge m:1 cd_a ent con v_sel tipo mes_cal using "`viv'", assert(match using) keep(match) nogen +merge m:1 cd_a ent con v_sel tipo mes_cal n_hog h_mud using "`hog'", assert(match using) keep(match) nogen + +count +assert `r(N)' == `num_rows' + +* Merge in the SINCO to ISCO codes - SINCO 19 USED +tostring coe1_p3, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_1 +drop sinco match + +tostring coe2_p7a, gen(sinco) format("%04.0f") +merge m:1 sinco using "`path_in_stata'/SINCO_19_ISCO_08.dta", keep(master match) nogen +rename isco isco_2 +drop sinco match + +*Merge in SCIAN codes - first and second job +gen scian = coe1_p4a +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_1 +drop scian + +gen scian = coe2_p7c +merge m:1 scian using "`path_in_stata'/SCIAN_18_ISIC_4.dta", keep(master match) nogen +rename isic isic_2 +drop scian + +* Save the file +save "`path_in_stata'/ENOE_2023.dta", replace + +*/ + +* Call the file directly (quicker) +* For the first time, use the above outcommented code +use "`path_in_stata'/ENOE_2023.dta", clear + + +/*%%============================================================================================= + 2: Survey & ID +==============================================================================================%%*/ + +{ + +*<_countrycode_> + gen str4 countrycode="MEX" + label var countrycode "Country code" +* + + +*<_survname_> + gen survname = "ENOE" + label var survname "Survey acronym" +* + + +*<_survey_> + gen survey = "LFS" + label var survey "Survey type" +* + + +*<_icls_v_> + gen icls_v = "ICLS-13" + label var icls_v "ICLS version(s) underlying questionnaire questions" +* + + +*<_isced_version_> + gen isced_version = "" + label var isced_version "Version of ISCED used for educat_isced" +* + + +*<_isco_version_> + gen isco_version = "isco_2008" + label var isco_version "Version of ISCO used" +* + gen isic_version = "isic_4" + label var isic_version "Version of ISIC used +* + + +*<_year_> + gen int year = 2023 + label var year "Year of survey" +* + + +*<_vermast_> + gen vermast = "`vermast'" + label var vermast "Version of master data" +* + + +*<_veralt_> + gen veralt = "`veralt'" + label var veralt "Version of the alt/harmonized data" +* + + +*<_harmonization_> + gen harmonization = "GLD" + label var harmonization "Type of harmonization" +* + + +*<_int_year_> + gen int_year = hog_p_anio + 2000 + label var int_year "Year of the interview" +* + + +*<_int_month_> + gen int_month = hog_p_mes + label de lblint_month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" + label value int_month lblint_month + label var int_month "Month of the interview" +* + + +*<_hhid_> +/* <_hhid_note> + + For ENOE-N years, we need the additional tipo (standard from now on) and mes_cal as well as + ca variables. According to CONEVAL in their ITPL calcualtions (*) ca is only necessary until + 2nd quarter 2021. We keep it nonetheless for consistency + + (*) - See codes in https://www.coneval.org.mx/Medicion/Paginas/ITLP-IS_pobreza_laboral.aspx + + */ + + tostring (ent v_sel mes_cal n_ren), gen(ent_str v_sel_str mes_cal_str n_ren_str) format("%02.0f") + tostring con, gen(con_str) format("%05.0f") + tostring (n_hog h_mud tipo), gen(n_hog_str h_mud_str tipo_str) format("%01.0f") + + egen hhid=concat(ent_str con_str v_sel_str n_hog_str h_mud_str tipo_str) + label var hhid "Household ID" + assert !missing(hhid) +* + + +*<_pid_> + egen pid = concat(hhid n_ren_str) + label var pid "Individual ID" +* + + +*<_weight_> + +/* <_weight_note> + + Weight is fac_tri: at quarter level, need to annualise. + Do this by obs numbers in each quarter + + */ + + gen help_1 = 1 + egen help_2 = total(help_1) + bys quarter : egen help_3 = total(help_1) + gen help_4 = help_3/help_2 + gen weight = fac_tri*help_4 + drop help_* + label var weight "Household sampling weight" +* + + +*<_weight_m_> + gen weight_m = fac_men + label var weight_m "Survey sampling weight to obtain national estimates for each month" +* + + +*<_weight_q_> + gen weight_q = fac_tri + label var weight_q "Survey sampling weight to obtain national estimates for each quarter" +* + + +*<_psu_> + gen psu = upm + label var psu "Primary sampling units" +* + + +*<_ssu_> + gen ssu = hhid + label var ssu "Secondary sampling units" +* + + +*<_strata_> + * Data has estrato for trimester & month. + * Monthly has missing values, go for quarter + gen strata = est_d_tri + label var strata "Strata" +* + + +*<_wave_> + gen str2 wave = "Q" + string(quarter) + label var wave "Survey wave" +* + + +*<_panel_> +/* <_panel_note> + + Panel = (year - 2005)*4 + alpha + (quarter - 1) + alpha = 5 - n_ent +1 + + *Where: + year: interview year + quarter: survey quarter + alpha: inverse of the visit number + n_ent: visit number + + */ + + gen alpha = 5 - n_ent + 1 + gen panel = (int_year - 2005) * 4 + alpha + (quarter - 1) + + * Place special panel for + label var panel "Panel individual belongs to" +* + + +*<_visit_no_> + gen visit_no = n_ent + label var visit_no "Visit number in panel" +* + + +*<_type_of_interview_> + +/* <_type_of_interview_note> + + Since ENOE-N, there are two kinds of interviews: face to face and by + telephone. The latter can occur more than once in a quarter. Need it + to differentiate. + + */ + gen type_of_interview = tipo + label var type_of_interview "Type of interview (in person or telephone)" + la de lbltype 1 "Face to face" 2 "Telephone" + label values type_of_interview lbltype +* + +} + + +/*%%============================================================================================= + 3: Geography +==============================================================================================%%*/ + +{ + +*<_urban_> + gen byte urban=. + replace urban=1 if inrange(t_loc_tri,1,3) + replace urban=0 if t_loc_tri==4 + label var urban "Location is urban" + la de lblurban 1 "Urban" 0 "Rural" + label values urban lblurban +* + + +*<_subnatid1_> + * State info in variable ent, is a labelled number + decode ent, gen(helper_lbl) + tostring ent, gen(helper_num) + gen subnatid1 = helper_num + " - " + helper_lbl + label var subnatid1 "Subnational ID at First Administrative Level" +* + + +*<_subnatid2_> +*selected main cities from states + gen byte subnatid2 = cd_a + * Unite urban complements + recode subnatid2 82/86=81 + label de lblsubnatid2 1 "1 - Mexico" 2 "2 - Guadalajara" 3 "3 - Monterrey" 4 "4 - Puebla" 5 "5 - Leon" 7 "6 - San Luis Potosi" 8 "7 - Merida" 9 "8 - Chihuahua" 10 " 9 - Tampico" 12 "10 - Veracruz" 13 "11 - Acapulco" 14 "12 - Aguacalientes" 15 "13 - Morelia" 16 "14 - Toluca" 17 "15 - Saltillo" 18 "16 - Villahermosa" 19 "17 - Tuxtla Gutierrez" 21 "18 - Tijuana" 24 "19 - Culiacan" 25 "20 - Hermosillo" 26 "21 - Durango" 27 "22 - Tepic" 28 "23 - Campeche" 29 "24 - Cuernavaca" 31 "25 - Oaxaca" 32 "26 - Zacatecas " 33 "27 - Colima" 36 "28 - Queretaro" 39 "29 - Tlaxcala" 40 "30 - La Paz " 41 "31 - Cancun" 43 "32 - Pachuca" 42 "33 - Ciudad del Carmen" 44 "34 - Mexicali" 46 "35 - Reynosa" 52 "36 Tapachula" 81 "99 - Complemento Urbano Rural", replace + label values subnatid2 lblsubnatid2 + decode subnatid2, gen(help_sub2) + drop subnatid2 + rename help_sub2 subnatid2 + label var subnatid2 "Subnational ID at Second Administrative Level" +* + + +*<_subnatid3_> +*selected towns within selected cities from states + gen byte subnatid3 = loc + label var subnatid3 "Subnational ID at Third Administrative Level" +* + + +*<_subnatidsurvey_> + gen subnatidsurvey = "subnatid2" + label var subnatidsurvey "Administrative level at which survey is representative" +* + + +*<_subnatid1_prev_> +/* <_subnatid1_prev> + + subnatid1_prev is coded as missing unless the classification used for subnatid1 has changed since the previous survey. + + */ + gen subnatid1_prev = . + label var subnatid1_prev "Classification used for subnatid1 from previous survey" +* + + +*<_subnatid2_prev_> + gen subnatid2_prev = . + label var subnatid2_prev "Classification used for subnatid2 from previous survey" +* + + +*<_subnatid3_prev_> + gen subnatid3_prev = . + label var subnatid3_prev "Classification used for subnatid3 from previous survey" +* + + +*<_gaul_adm1_code_> + gen gaul_adm1_code = . + label var gaul_adm1_code "Global Administrative Unit Layers (GAUL) Admin 1 code" +* + + +*<_gaul_adm2_code_> + gen gaul_adm2_code = . + label var gaul_adm2_code "Global Administrative Unit Layers (GAUL) Admin 2 code" +* + + +*<_gaul_adm3_code_> + gen gaul_adm3_code = . + label var gaul_adm3_code "Global Administrative Unit Layers (GAUL) Admin 3 code" +* + +} + +/*%%============================================================================================= + 4: Demography +==============================================================================================%%*/ + +{ + +*<_hsize_> + bysort hhid quarter: gen hsize=_N if sdem_par_c<400 | inrange(sdem_par_c,600,999) + * Domestic workers (codes 600), Guests (700s) and non-defined (999) are + * not counted + label var hsize "Household size" +* + + +*<_age_> + gen age = sdem_eda + replace age = . if sdem_eda == 99 + replace age = . if sdem_eda == 99 + label var age "Individual age" +* + + +*<_male_> + gen male = sdem_sex + recode male 2=0 + label var male "Sex - Ind is male" + la de lblmale 1 "Male" 0 "Female" + label values male lblmale +* + + +*<_relationharm_> + gen relationharm = . + replace relationharm = 1 if sdem_par_c == 101 + replace relationharm = 2 if sdem_par_c == 201 + replace relationharm = 5 if inrange(sdem_par_c, 202, 204) // Other partners, not spouse + replace relationharm = 3 if inrange(sdem_par_c, 301, 304) + replace relationharm = 4 if inrange(sdem_par_c, 401, 402) + replace relationharm = 5 if inrange(sdem_par_c, 403, 424) + replace relationharm = 6 if inrange(sdem_par_c, 501, 999) + + la de lblrelationharm 1 "Head of household" 2 "Spouse" 3 "Children" 4 "Parents" 5 "Other relatives" 6 "Other and non-relatives", replace + label values relationharm lblrelationharm +* + + +*<_relationcs_> + gen relationcs = sdem_par_c + label var relationcs "Relationship to the head of household - Country original" +* + + +*<_marital_> + gen byte marital = sdem_e_con + recode marital 1=3 2=4 3=4 4=5 5=1 6=2 9=. + label var marital "Marital status" + la de lblmarital 1 "Married" 2 "Never Married" 3 "Living together" 4 "Divorced/Separated" 5 "Widowed" + label values marital lblmarital +* + + +*<_eye_dsablty_> + gen eye_dsablty = . + label var eye_dsablty "Disability related to eyesight" +* + + +*<_hear_dsablty_> + gen hear_dsablty = . + label var eye_dsablty "Disability related to hearing" +* + + +*<_walk_dsablty_> + gen walk_dsablty = . + label var eye_dsablty "Disability related to walking or climbing stairs" +* + + +*<_conc_dsord_> + gen conc_dsord = . + label var eye_dsablty "Disability related to concentration or remembering" +* + + +*<_slfcre_dsablty_> + gen slfcre_dsablty = . + label var eye_dsablty "Disability related to selfcare" +* + + +*<_comm_dsablty_> + gen comm_dsablty = . + label var eye_dsablty "Disability related to communicating" +* + +} + + +/*%%============================================================================================= + 5: Migration +==============================================================================================%%*/ + + +{ + +*<_migrated_mod_age_> + gen migrated_mod_age = 1 + label var migrated_mod_age "Migration module application age" +* + + +*<_migrated_ref_time_> + gen migrated_ref_time = 1 + label var migrated_ref_time "Reference time applied to migration questions (in years)" +* + + +*<_migrated_binary_> + gen migrated_binary = 0 + * Migrated if either in different country or state (20a) or a different municipality (20b) + replace migrated_binary = 1 if inrange(sdem_cs_p20a_1,2,4) | sdem_cs_p20b_1 == 2 + label de lblmigrated_binary 0 "No" 1 "Yes", replace + label values migrated_binary lblmigrated_binary + label var migrated_binary "Individual has migrated" +* + + +*<_migrated_years_> + gen migrated_years = . + label var migrated_years "Years since latest migration" +* + + +*<_migrated_from_urban_> + gen migrated_from_urban = . + label de lblmigrated_from_urban 0 "Rural" 1 "Urban" + label values migrated_from_urban lblmigrated_from_urban + label var migrated_from_urban "Migrated from area" +* + + +*<_migrated_from_cat_> + gen migrated_from_cat = . + replace migrated_from_cat = 3 if sdem_cs_p20a_1 == 1 & sdem_cs_p20b_1 == 2 + replace migrated_from_cat = 4 if sdem_cs_p20a_1 == 2 + replace migrated_from_cat = 5 if inrange(sdem_cs_p20a_1,3,4) + replace migrated_from_cat = . if migrated_binary == 1 + label de lblmigrated_from_cat 1 "From same admin3 area" 2 "From same admin2 area" 3 "From same admin1 area" 4 "From other admin1 area" 5 "From other country" + label values migrated_from_cat lblmigrated_from_cat + label var migrated_from_cat "Category of migration area" +* + + +*<_migrated_from_code_> + * We want to code this as subnatid1, use that info to merge it in + gen mig_code_helper = sdem_cs_p20a_c if sdem_cs_p20a_c < 100 & migrated_binary == 1 + preserve + + keep subnatid1 + rename subnatid1 long_name + gen counter = 1 + collapse (rawsum) counter, by(long_name) + drop counter + gen mig_code_helper = substr(long_name,1,2) + destring mig_code_helper, replace + tempfile mig_helper + save "`mig_helper'" + + restore + + merge m:1 mig_code_helper using "`mig_helper'", assert(match master) nogen + + gen migrated_from_code = long_name + drop long_name mig_code_helper + label var migrated_from_code "Code of migration area as subnatid level of migrated_from_cat" +* + + +*<_migrated_from_country_> + gen migrated_from_country = "" + replace migrated_from_country = "AGO" if sdem_cs_p20a_c == 101 + replace migrated_from_country = "GIN" if sdem_cs_p20a_c == 123 + replace migrated_from_country = "ARG" if sdem_cs_p20a_c == 204 + replace migrated_from_country = "BLZ" if sdem_cs_p20a_c == 208 + replace migrated_from_country = "BOL" if sdem_cs_p20a_c == 210 + replace migrated_from_country = "BRA" if sdem_cs_p20a_c == 211 + replace migrated_from_country = "CAN" if sdem_cs_p20a_c == 213 + replace migrated_from_country = "COL" if sdem_cs_p20a_c == 214 + replace migrated_from_country = "CRI" if sdem_cs_p20a_c == 215 + replace migrated_from_country = "CUB" if sdem_cs_p20a_c == 216 + replace migrated_from_country = "CHL" if sdem_cs_p20a_c == 217 + replace migrated_from_country = "ECU" if sdem_cs_p20a_c == 219 + replace migrated_from_country = "SLV" if sdem_cs_p20a_c == 220 + replace migrated_from_country = "USA" if sdem_cs_p20a_c == 221 + replace migrated_from_country = "GTM" if sdem_cs_p20a_c == 225 + replace migrated_from_country = "HTI" if sdem_cs_p20a_c == 228 + replace migrated_from_country = "HND" if sdem_cs_p20a_c == 229 + replace migrated_from_country = "NIC" if sdem_cs_p20a_c == 234 + replace migrated_from_country = "PAN" if sdem_cs_p20a_c == 235 + replace migrated_from_country = "PER" if sdem_cs_p20a_c == 237 + replace migrated_from_country = "PRI" if sdem_cs_p20a_c == 238 + replace migrated_from_country = "DOM" if sdem_cs_p20a_c == 239 + replace migrated_from_country = "SUR" if sdem_cs_p20a_c == 244 + replace migrated_from_country = "URY" if sdem_cs_p20a_c == 247 + replace migrated_from_country = "VEN" if sdem_cs_p20a_c == 250 + replace migrated_from_country = "KOR" if sdem_cs_p20a_c == 313 + replace migrated_from_country = "CHN" if sdem_cs_p20a_c == 315 + replace migrated_from_country = "JPN" if sdem_cs_p20a_c == 330 + replace migrated_from_country = "SGP" if sdem_cs_p20a_c == 346 + replace migrated_from_country = "ESP" if sdem_cs_p20a_c == 415 + replace migrated_from_country = "FIN" if sdem_cs_p20a_c == 418 + replace migrated_from_country = "FRA" if sdem_cs_p20a_c == 419 + replace migrated_from_country = "ITA" if sdem_cs_p20a_c == 425 + replace migrated_from_country = "POL" if sdem_cs_p20a_c == 437 + replace migrated_from_country = "GBR" if sdem_cs_p20a_c == 439 + replace migrated_from_country = "CZE" if sdem_cs_p20a_c == 440 + replace migrated_from_country = "RUS" if sdem_cs_p20a_c == 442 + replace migrated_from_country = "CHE" if sdem_cs_p20a_c == 446 + + label var migrated_from_country "Code of migration country (ISO 3 Letter Code)" +* + + +*<_migrated_reason_> + gen migrated_reason = sdem_cs_p20c_1 + recode migrated_reason (3 4 = 1) (5 = 2) (1 2 = 3) (6 7 9 = 4) (8 10 11 = 5) + label de lblmigrated_reason 1 "Family reasons" 2 "Educational reasons" 3 "Employment" 4 "Forced (political reasons, natural disaster, …)" 5 "Other reasons" + label values migrated_reason lblmigrated_reason + label var migrated_reason "Reason for migrating" +* + +} + + +/*%%============================================================================================= + 6: Education +==============================================================================================%%*/ + + +{ + +*<_ed_mod_age_> + +/* <_ed_mod_age_note> + +Education module is only asked to those XX and older. + + */ + + gen byte ed_mod_age = 5 + label var ed_mod_age "Education module application age" + +* + +*<_school_> + gen byte school = sdem_cs_p17 + recode school (2 = 0) (9 = .) + label var school "Attending school" + la de lblschool 0 "No" 1 "Yes" + label values school lblschool +* + + +*<_literacy_> + gen byte literacy = sdem_cs_p12 + recode literacy (2 = 0) (9 = .) + label var literacy "Individual can read & write" + la de lblliteracy 0 "No" 1 "Yes" + label values literacy lblliteracy +* + + +*<_educy_> + * No Education and Pre-Primary OR Primary with Zero Years + gen byte educy = 0 if (sdem_cs_p13_1 == 0 | sdem_cs_p13_1 == 1) /// + | (sdem_cs_p13_1 == 2 & sdem_cs_p13_2 == 0) + + * Primary School + replace educy=1 if sdem_cs_p13_1==2 & sdem_cs_p13_2==1 + replace educy=2 if sdem_cs_p13_1==2 & sdem_cs_p13_2==2 + replace educy=3 if sdem_cs_p13_1==2 & sdem_cs_p13_2==3 + replace educy=4 if sdem_cs_p13_1==2 & sdem_cs_p13_2==4 + replace educy=5 if sdem_cs_p13_1==2 & sdem_cs_p13_2==5 + replace educy=6 if sdem_cs_p13_1==2 & sdem_cs_p13_2>=6 & sdem_cs_p13_2!=. + + * Carrera Tecnica con antecedente Primaria OR Primaria + replace educy=7 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==1 + replace educy=8 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2==2 + replace educy=9 if ((sdem_cs_p13_1==6 & sdem_cs_p15==1) | sdem_cs_p13_1==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Normal con Antecedente Primaria + replace educy=7 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==1 + replace educy=8 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2==2 + replace educy=9 if (sdem_cs_p13_1==5 & sdem_cs_p15==1) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * Prepa OR Carrera Tecnica con antecedente secundaria + * + años de escolaridad + replace educy=10 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==4 | (sdem_cs_p13_1==6 & sdem_cs_p15==2)) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con Antecedente Secundaria + replace educy=10 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==1 + replace educy=11 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==2 + replace educy=12 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2==3 + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==2) & sdem_cs_p13_2>=4 & sdem_cs_p13_2!=. + + * Profesional without any years + replace educy=12 if ((sdem_cs_p13_1==7 & sdem_cs_p13_2==0)) + + * Profesional con antecedente bachillerato + replace educy=13 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==7 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Carrera Tecnica con Antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==6 & sdem_cs_p15==3) & sdem_cs_p13_2>=3 & sdem_cs_p13_2!=. + + * NORMAL con antecedente Preparatoria + replace educy=13 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==1 + replace educy=14 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==2 + replace educy=15 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==3 + replace educy=16 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2==4 + replace educy=17 if (sdem_cs_p13_1==5 & sdem_cs_p15==3) & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=. + + * Maestria + replace educy=18 if sdem_cs_p13_1==8 & sdem_cs_p13_2==1 + replace educy=19 if sdem_cs_p13_1==8 & sdem_cs_p13_2>=2 & sdem_cs_p13_2!=. + + * Doctorado + replace educy=18 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==1) + replace educy=19 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==2) + replace educy=20 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==3) + replace educy=21 if (sdem_cs_p13_1==9 & sdem_cs_p13_2==4) + replace educy=22 if (sdem_cs_p13_1==9 & sdem_cs_p13_2>=5 & sdem_cs_p13_2!=.) + + * Missing and Zeros + replace educy=0 if (sdem_cs_p13_1==0 | sdem_cs_p13_1==1) |(sdem_cs_p13_1==2 & sdem_cs_p13_2==0) + replace educy=. if (sdem_cs_p13_1==99 | sdem_cs_p13_2==9 | sdem_cs_p15==9) + replace educy=. if age + + +*<_educat7_> + *gen byte educat7 = + gen byte educat7=1 if educy==0 + replace educat7=2 if sdem_cs_p13_1==2 + replace educat7=3 if educy==6 & sdem_cs_p13_1==2 + replace educat7=4 if inrange(sdem_cs_p13_1,3,4) + replace educat7=5 if educy==12 & sdem_cs_p13_1==4 + replace educat7=6 if inrange(sdem_cs_p13_1,5,6) + replace educat7=7 if inrange(sdem_cs_p13_1,7,9) + replace educat7=. if age + + +*<_educat5_> + gen byte educat5 = educat7 + recode educat5 4=3 5=4 6 7=5 + label var educat5 "Level of education 2" + la de lbleducat5 1 "No education" 2 "Primary incomplete" 3 "Primary complete but secondary incomplete" 4 "Secondary complete" 5 "Some tertiary/post-secondary" + label values educat5 lbleducat5 +* + + +*<_educat4_> + gen byte educat4 = educat7 + recode educat4 (2 3 4=2) (5=3) (6 7=4 ) + label var educat4 "Level of education 3" + la de lbleducat4 1 "No education" 2 "Primary" 3 "Secondary" 4 "Post-secondary" + label values educat4 lbleducat4 +* + +*<_educat_orig_> + gen educat_orig = . + label var educat_orig "Original survey education code" + *Note: The ENOE uses the national education classification which needs two variables + *sdem_cs_p13_1 (school level) & sdem_cs_p13_2(years in school) to create one measurement of + *education level as a result there is no unique variable that + *translate to educat_orig. See documentation references for more details. +* + +*<_educat_isced_> + gen educat_isced = . + label var educat_isced "ISCED standardised level of education" +* + + +*----------6.1: Education cleanup------------------------------* + +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) +local ed_var "school literacy educy educat7 educat5 educat4 educat_isced" +foreach v of local ed_var { + replace `v'=. if ( age < ed_mod_age & !missing(age) ) +} + +* + + +} + + + +/*%%============================================================================================= + 7: Training +==============================================================================================%%*/ + + +{ + +*<_vocational_> + gen vocational = . + label de lblvocational 0 "No" 1 "Yes" + label var vocational "Ever received vocational training" +* + +*<_vocational_type_> + gen vocational_type = . + label de lblvocational_type 1 "Inside Enterprise" 2 "External" + label values vocational_type lblvocational_type + label var vocational_type "Type of vocational training" +* + +*<_vocational_length_l_> + gen vocational_length_l = . + label var vocational_length_l "Length of training, lower limit" +* + +*<_vocational_length_u_> + gen vocational_length_u = . + label var vocational_length_u "Length of training, upper limit" +* + +*<_vocational_field_orig_> + gen vocational_field_orig = . + label var vocational_field_orig "Field of training" +* + +*<_vocational_financed_> + gen vocational_financed = . + label de lblvocational_financed 1 "Employer" 2 "Government" 3 "Mixed Employer/Government" 4 "Own funds" 5 "Other" + label var vocational_financed "How training was financed" +* + +} + +/*%%============================================================================================= + 8: Labour +==============================================================================================%%*/ + + +*<_minlaborage_> + gen byte minlaborage = 12 + label var minlaborage "Labor module application age" +* + + +*----------8.1: 7 day reference overall------------------------------* + +{ +*<_lstatus_> + + gen byte lstatus=1 if inlist(coe1_p1,1,2) | coe1_p1a1==1 | coe1_p1a2==2 /// + | coe1_p1b==1 | inrange(coe1_p1c,1,4) | coe1_p1d==1 | coe1_p1e==1 + replace lstatus=2 if (coe1_p2_1==1 | coe1_p2_2==2 | coe1_p2_3==3) + replace lstatus=3 if coe1_p2_4==4 + replace lstatus=. if age < minlaborage & age != . + label var lstatus "Labor status" + la de lbllstatus 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus lbllstatus +* + + +*<_potential_lf_> + gen byte potential_lf = . + replace potential_lf=1 if lstatus==3 + replace potential_lf = . if age < minlaborage & age != . + replace potential_lf = 0 if lstatus != 3 + label var potential_lf "Potential labour force status" + la de lblpotential_lf 0 "No" 1 "Yes" + label values potential_lf lblpotential_lf +* + + +*<_underemployment_> + gen byte underemployment = . + label var underemployment "Underemployment status" + la de lblunderemployment 0 "No" 1 "Yes" + label values underemployment lblunderemployment +* + + +*<_nlfreason_> + gen byte nlfreason = coe1_p2e + *Set the "don't know (9)" responses to missing + recode nlfreason 3=1 2=3 4=2 5=4 1=5 6=5 9=. + replace nlfreason=. if lstatus!=3 + label var nlfreason "Reason not in the labor force" + la de lblnlfreason 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disabled" 5 "Other" + label values nlfreason lblnlfreason +* + + +*<_unempldur_l_> + gen byte unempldur_l=. + label var unempldur_l "Unemployment duration (months) lower bracket" + label values unempldur_l lblune +* + + +*<_unempldur_u_> + gen byte unempldur_u=. + label var unempldur_u "Unemployment duration (months) upper bracket" + label values unempldur_u lblune_2 +* + +} + + +*----------8.2: 7 day reference main job------------------------------* + + +{ + +*<_empstat_> + gen empstat = . + + * Employee if doesn't work on their own (p3b is 2 or missing), gets pay + replace empstat = 1 if inlist(coe1_p3b,.,2) & coe1_p3h == 1 + + * Non paid employee if as above, yet no pay + replace empstat = 2 if inlist(coe1_p3b,.,2) & inrange(coe1_p3h,2,3) + + * Employer works own account, has employees they pay (3G1_1 = 1) + replace empstat = 3 if coe1_p3b == 1 & coe1_p3g1_1 == 1 + + * Self employed works own account, has no paid employees + replace empstat = 4 if coe1_p3b == 1 & coe1_p3g1_1 != 1 + + label var empstat "Employment status during past week primary job 7 day recall" + la de lblempstat 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat lblempstat +* + + +*<_ocusec_> + gen byte ocusec = . + + * Note that any "agropecuario" (agriculture and fishing) skips the questions + + * If activity is in private sector (4B = 4) o undetermined (4B = 5) + * yet independent or private (4C = 1|2) + replace ocusec = 2 if (coe1_p4b == 4) | /// + (coe1_p4b == 5 & inrange(coe1_p4c, 1, 2)) + + * If education/hospital (4B = 2) or public or non-profit (4B = 3), then 4D decides + * Public: All options administered by government (4D1 == 1) + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 1 & inrange(coe1_p4d2,1,7) + * Public Among not administered by government (4D1 == 2, public education, independent orgs (Election Commission), International Orgs + replace ocusec = 1 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,2,3,6) + + * Private: Not administered by gov, not the above + replace ocusec = 2 if (inrange(coe1_p4b, 2, 3)) & coe1_p4d1 == 2 & inlist(coe1_p4d2,1,4,5,7) + + * In agriculture and not paid employee + replace ocusec = 2 if coe1_p4b == 1 & inrange(empstat,2,4) + + * A lot of the people still undefined are classified in industry as house staff + * industry_orig 8140. This we code as private sector + replace ocusec = 2 if mi(ocusec) & coe1_p4a == 8140 + + replace ocusec=. if lstatus!=1 + label var ocusec "Sector of activity primary job 7 day recall" + la de lblocusec 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec lblocusec +* + + +*<_industry_orig_> + gen industry_orig = coe1_p4a + replace industry_orig = . if age < minlaborage & age != . + replace industry_orig=. if lstatus!=1 + label var industry_orig "Original survey industry code, main job 7 day recall" +* + + +*<_industrycat_isic_> + gen industrycat_isic= isic_1 + replace industrycat_isic="" if lstatus!=1 + label var industrycat_isic "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_> + destring isic_1, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10 = . + replace industrycat10 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10 = 1 if inlist(isic_1, "A") & mi(industrycat10) + replace industrycat10 = 2 if inlist(isic_1, "B") & mi(industrycat10) + replace industrycat10 = 3 if inlist(isic_1, "C") & mi(industrycat10) + replace industrycat10 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10) + replace industrycat10 = 5 if inlist(isic_1, "F") & mi(industrycat10) + replace industrycat10 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10) + replace industrycat10 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10) + replace industrycat10 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10) + replace industrycat10 = 9 if inlist(isic_1, "O") & mi(industrycat10) + replace industrycat10 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10) + + replace industrycat10 = . if lstatus!=1 + drop ind_helper + label var industrycat10 "1 digit industry classification, primary job 7 day recall" + la de lblindustrycat10 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10 lblindustrycat10 +* + + +*<_industrycat4_> + gen byte industrycat4 = industrycat10 + recode industrycat4 (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4 "1 digit industry classification (Broad Economic Activities), primary job 7 day recall" + la de lblindustrycat4 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4 lblindustrycat4 + replace industrycat4=. if lstatus!=1 +* + + +*<_occup_orig_> + gen occup_orig = coe1_p3 + label var occup_orig "Original occupation record primary job 7 day recall" +* + + +*<_occup_> + destring isco_1, gen(occup_helper) + gen byte occup = floor(occup_helper/1000) + replace occup = 10 if occup == 0 + drop occup_helper + label var occup "1 digit occupational classification, primary job 7 day recall" + la de lbloccup 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup lbloccup + replace occup = . if lstatus!=1 +* + + +*<_occup_isco_> + gen occup_isco = isco_1 + replace occup_isco = "" if lstatus!=1 + label var occup_isco "ISCO code of primary job 7 day recall" +* + + +*<_occup_skill_> + gen occup_skill = . + replace occup_skill = 1 if occup == 9 + replace occup_skill = 2 if inrange(occup, 4, 8) + replace occup_skill = 3 if inrange(occup, 1, 3) + replace occup_skill = . if lstatus != 1 + la de lblskill 1 "Low skill" 2 "Medium skill" 3 "High skill" + label values occup_skill lbloccupskill + label var occup_skill "Skill based on ISCO standard primary job 7 day recall" +* + + +*<_wage_no_compen_> + gen double wage_no_compen =. + replace wage_no_compen = coe2_p6b2 if lstatus==1 + + * There are also people who estimate their salary. We us the people in those + * categories to estimate that of others. Note that there are two salary zones + * so we need to run this twice + + foreach i of numlist 1/2 { + + preserve + + * First store minimum salaries + summ sdem_salario if sdem_zona == `i' + local min_sal_`i' `r(mean)' + + gen salary_cat = . + replace salary_cat = 1 if wage_no_compen < `min_sal_`i'' + replace salary_cat = 2 if wage_no_compen == `min_sal_`i'' + replace salary_cat = 3 if wage_no_compen > `min_sal_`i'' & wage_no_compen <= `min_sal_`i''*2 + replace salary_cat = 4 if wage_no_compen > `min_sal_`i''*2 & wage_no_compen <= `min_sal_`i''*3 + replace salary_cat = 5 if wage_no_compen > `min_sal_`i''*3 & wage_no_compen <= `min_sal_`i''*5 + replace salary_cat = 6 if wage_no_compen > `min_sal_`i''*5 & wage_no_compen <= `min_sal_`i''*10 + replace salary_cat = 7 if wage_no_compen > `min_sal_`i''*10 & !mi(wage_no_compen) + + * Collapse, prep data + collapse (p50) wage_no_compen, by(salary_cat) + rename wage_no_compen salary_estimate + rename salary_cat coe2_p6c + gen sdem_zona = `i' + + * If first round, save; if second, append and save + if `i' == 1 { + + tempfile wage_helper_1 + save "`wage_helper_1'" + + } + + else { + + append using "`wage_helper_1'" + tempfile wage_helper + save "`wage_helper'" + + } + + + restore + + } + + merge m:1 coe2_p6c sdem_zona using "`wage_helper'", assert(match master) nogen + + * Now assign salary by category estimates with the medians of those in that category + replace wage_no_compen = salary_estimate if !mi(salary_estimate) & mi(wage_no_compen) + + * Assign minimum salary for those (very few, not in categories) who claim to get exactly + * the minimum salary (coe2_p6c == 2) + foreach i of numlist 1/2 { + + summ sdem_salario if sdem_zona == `i' + local min_sal `r(mean)' + replace wage_no_compen = `min_sal' if mi(wage_no_compen) & sdem_zona == `i' & coe2_p6c == 2 + + } + + replace wage_no_compen = 0 if empstat==2 + replace wage_no_compen = . if lstatus!=1 + label var wage_no_compen "Last wage payment primary job 7 day recall" +* + + +*<_unitwage_> + * Questionnaire has different options, but salary is already made to + * fit monthly + gen byte unitwage = 5 + label var unitwage "Last wages' time unit primary job 7 day recall" + la de lblunitwage 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + replace unitwage = . if wage_no_compen==. + label values unitwage lblunitwage +* + + +*<_whours_> + * Var differs if extended or basic questionnaire + * Generate unified vars - values differ if extended or basic survey + gen hlp_whours_usual_bin = . + replace hlp_whours_usual_bin = coe1_p5c if inrange(quarter, 2, 4) + replace hlp_whours_usual_bin = coe1_p5d if quarter == 1 + + gen hlp_whours_lw = . + replace hlp_whours_lw = coe1_p5b_thrs if inrange(quarter, 2, 4) + replace hlp_whours_lw = coe1_p5c_thrs if quarter == 1 + + gen hlp_whours_nw = . + replace hlp_whours_nw = coe1_p5d_thrs if inrange(quarter, 2, 4) + replace hlp_whours_nw = coe1_p5e_thrs if quarter == 1 + + * Generate actual var + gen whours = hlp_whours_lw + *replace if not the usual hours in the week + replace whours = hlp_whours_nw if hlp_whours_usual_bin == 2 + replace whours = . if lstatus != 1 + replace whours = . if inlist(whours, 0, 999) + label var whours "Hours of work in last week primary job 7 day recall" + drop hlp_whours_* +* + + +*<_wmonths_> +* Var changes if extended or basic questionnaire, unify +foreach num of numlist 1/15 99 { + + gen hlp_wmonths_`num' = . + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5f`num') & inrange(quarter, 2, 4) + replace hlp_wmonths_`num' = 1 if !mi(coe1_p5g`num') & quarter == 1 + +} + + egen wmonths = rowtotal(hlp_wmonths_1 - hlp_wmonths_12), missing + replace wmonths = 12 if hlp_wmonths_14 == 1 + replace wmonths = . if hlp_wmonths_13 == 1 | hlp_wmonths_15 == 1 | hlp_wmonths_99 == 1 + replace wmonths = . if lstatus!=1 + label var wmonths "Months of work in past 12 months primary job 7 day recall" + drop hlp_wmonths_* +* + + +*<_wage_total_> +/* <_wage_total> + + Use gross wages when available and net wages only when gross wages are not available. + This is done to make it easy to compare earnings in formal and informal sectors. + + */ + gen double wage_total=. + replace wage_total = (wage_no_compen)*wmonths + replace wage_total = . if lstatus != 1 + label var wage_total "Annualized total wage primary job 7 day recall" +* + + +*<_contract_> + * Contract is 3J in extended, 3I in basic questionnaire + gen byte contract = . + replace contract = coe1_p3i if inrange(quarter,2,4) + replace contract = coe1_p3j if quarter == 1 + recode contract (2 = 0) (9 = .) + replace contract=. if lstatus!=1 + label var contract "Employment has contract primary job 7 day recall" + la de lblcontract 0 "Without contract" 1 "With contract" + label values contract lblcontract +* + + + +*<_healthins_> + gen byte healthins = . + label var healthins "Employment has health insurance primary job 7 day recall" + la de lblhealthins 0 "Without health insurance" 1 "With health insurance" + label values healthins lblhealthins +* + + +*<_socialsec_> + gen byte socialsec = . + label var socialsec "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec 1 "With social security" 0 "Without social secturity" + label values socialsec lblsocialsec +* + + +*<_union_> + * Only in extended questionnaire + gen byte union = coe1_p3i if quarter == 1 + recode union (2 = 0) (9 = .) + label var union "Union membership at primary job 7 day recall" + la de lblunion 0 "Not union member" 1 "Union member" + label values union lblunion +* + + +*<_firmsize_l_> + + * Firmsize for employees is 3Q in extended questionnaire, 3L in basic + gen helper_fs = . + replace helper_fs = coe1_p3l if inrange(quarter,2,4) + replace helper_fs = coe1_p3q if quarter == 1 + + gen byte firmsize_l = . + replace firmsize_l = 1 if helper_fs == 1 + replace firmsize_l = 2 if helper_fs == 2 + replace firmsize_l = 6 if helper_fs == 3 + replace firmsize_l = 11 if helper_fs == 4 + replace firmsize_l = 16 if helper_fs == 5 + replace firmsize_l = 21 if helper_fs == 6 + replace firmsize_l = 31 if helper_fs == 7 + replace firmsize_l = 51 if helper_fs == 8 + replace firmsize_l = 101 if helper_fs == 9 + replace firmsize_l = 251 if helper_fs == 10 + replace firmsize_l = 501 if helper_fs == 11 + + * Add self-employed + replace firmsize_l = 1 if empstat == 4 + + * Add employer + replace firmsize_l = 2 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_l = 6 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_l = 11 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_l = 16 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_l = 21 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_l = 31 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_l = 51 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_l = 101 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_l = 251 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_l = 501 if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_l=. if lstatus!=1 + + label var firmsize_l "Firm size (lower bracket) primary job 7 day recall" +* + + +*<_firmsize_u_> + gen byte firmsize_u = . + replace firmsize_u = 1 if helper_fs == 1 + replace firmsize_u = 5 if helper_fs == 2 + replace firmsize_u = 10 if helper_fs == 3 + replace firmsize_u = 15 if helper_fs == 4 + replace firmsize_u = 20 if helper_fs == 5 + replace firmsize_u = 30 if helper_fs == 6 + replace firmsize_u = 50 if helper_fs == 7 + replace firmsize_u = 100 if helper_fs == 8 + replace firmsize_u = 250 if helper_fs == 9 + replace firmsize_u = 500 if helper_fs ==10 + replace firmsize_u = . if helper_fs ==11 + + * Add self-employed + replace firmsize_u = 1 if empstat == 4 + + * Add employer + replace firmsize_u = 5 if inrange(coe1_p3g_tot, 1, 4) + replace firmsize_u = 10 if inrange(coe1_p3g_tot, 5, 9) + replace firmsize_u = 15 if inrange(coe1_p3g_tot, 10, 14) + replace firmsize_u = 20 if inrange(coe1_p3g_tot, 15, 19) + replace firmsize_u = 30 if inrange(coe1_p3g_tot, 20, 29) + replace firmsize_u = 50 if inrange(coe1_p3g_tot, 30, 49) + replace firmsize_u = 100 if inrange(coe1_p3g_tot, 50, 99) + replace firmsize_u = 250 if inrange(coe1_p3g_tot, 100, 249) + replace firmsize_u = 500 if inrange(coe1_p3g_tot, 250, 499) + replace firmsize_u = . if inrange(coe1_p3g_tot, 500, 999999) + + replace firmsize_u=. if lstatus!=1 + label var firmsize_u "Firm size (upper bracket) primary job 7 day recall" +* + +} + + +*----------8.3: 7 day reference secondary job------------------------------* +* Since labels are the same as main job, values are labelled using main job labels + + +{ +*<_empstat_2_> + gen byte empstat_2 = coe2_p7 + recode empstat_2 (4 5 = 1) (6 = 2) (1 2 3 = 4) (7 9 = .) + replace empstat_2 = . if lstatus!=1 + label var empstat_2 "Employment status during past week secondary job 7 day recall" + label values empstat_2 lblempstat +* + + +*<_ocusec_2_> + gen byte ocusec_2 = . + label var ocusec_2 "Sector of activity secondary job 7 day recall" + label values ocusec_2 lblocusec +* + + +*<_industry_orig_2_> + gen industry_orig_2 = coe2_p7c + replace industry_orig_2 = . if mi(empstat_2) + label var industry_orig_2 "Original survey industry code, secondary job 7 day recall" +* + + +*<_industrycat_isic_2_> + gen industrycat_isic_2 = isic_2 + replace industrycat_isic_2 = "" if mi(empstat_2) + label var industrycat_isic_2 "ISIC code of primary job 7 day recall" +* + + +*<_industrycat10_2_> + destring isic_2, gen(ind_helper) force + replace ind_helper = floor(ind_helper/100) + + * Use IND Helper to create categories + gen industrycat10_2 = . + replace industrycat10_2 = 1 if inrange(ind_helper, 1, 3) + replace industrycat10_2 = 2 if inrange(ind_helper, 5, 9) + replace industrycat10_2 = 3 if inrange(ind_helper, 10, 33) + replace industrycat10_2 = 4 if inrange(ind_helper, 35, 39) + replace industrycat10_2 = 5 if inrange(ind_helper, 41, 43) + replace industrycat10_2 = 6 if inrange(ind_helper, 45, 47) | inrange(ind_helper, 55, 56) + replace industrycat10_2 = 7 if inrange(ind_helper, 49, 53) | inrange(ind_helper, 58, 63) + replace industrycat10_2 = 8 if inrange(ind_helper, 64, 82) + replace industrycat10_2 = 9 if inrange(ind_helper, 84, 84) + replace industrycat10_2 = 10 if inrange(ind_helper, 85, 99) + + * Add in cases with letters + replace industrycat10_2 = 1 if inlist(isic_1, "A") & mi(industrycat10_2) + replace industrycat10_2 = 2 if inlist(isic_1, "B") & mi(industrycat10_2) + replace industrycat10_2 = 3 if inlist(isic_1, "C") & mi(industrycat10_2) + replace industrycat10_2 = 4 if inlist(isic_1, "D", "E") & mi(industrycat10_2) + replace industrycat10_2 = 5 if inlist(isic_1, "F") & mi(industrycat10_2) + replace industrycat10_2 = 6 if inlist(isic_1, "G", "I") & mi(industrycat10_2) + replace industrycat10_2 = 7 if inlist(isic_1, "H", "J") & mi(industrycat10_2) + replace industrycat10_2 = 8 if inlist(isic_1, "K", "L", "M", "N") & mi(industrycat10_2) + replace industrycat10_2 = 9 if inlist(isic_1, "O") & mi(industrycat10_2) + replace industrycat10_2 = 10 if inlist(isic_1, "P", "Q", "R", "S", "T", "U") & mi(industrycat10_2) + + replace industrycat10_2 = . if mi(empstat_2) + drop ind_helper + + label values industrycat10_2 lblindustrycat10 +* + + +*<_industrycat4_2_> + gen byte industrycat4_2 = industrycat10_2 + recode industrycat4_2 (1 = 1) (2 3 4 5 = 2) (6 7 8 9 = 3) (10 = 4) + label var industrycat4_2 "1 digit industry classification (Broad Economic Activities), secondary job 7 day recall" + label values industrycat4_2 lblindustrycat4 +* + + +*<_occup_orig_2_> + gen occup_orig_2 = coe2_p7a + label var occup_orig_2 "Original occupation record secondary job 7 day recall" +* + + +*<_occup_2_> + destring isco_2, gen(occup_helper_2) + gen byte occup_2 = floor(occup_helper_2/1000) + replace occup_2 = 10 if occup_2 == 0 + drop occup_helper_2 + label var occup_2 "1 digit occupational classification secondary job 7 day recall" + label values occup_2 lbloccup +* + + +*<_occup_isco_2_> + gen occup_isco_2 = isco_2 + replace occup_isco_2 = "" if mi(empstat_2) + label var occup_isco_2 "ISCO code of secondary job 7 day recall" +* + + +*<_occup_skill_2_> + gen occup_skill_2 = . + replace occup_skill_2 = 1 if occup_2 == 9 + replace occup_skill_2 = 2 if inrange(occup_2, 4, 8) + replace occup_skill_2 = 3 if inrange(occup_2, 1, 3) + replace occup_skill_2 = . if mi(empstat_2) + label var occup_skill_2 "Skill based on ISCO standard secondary job 7 day recall" + label values occup_skill_2 lbloccupskill +* + + +*<_wage_no_compen_2_> + gen double wage_no_compen_2 = . + label var wage_no_compen_2 "Last wage payment secondary job 7 day recall" +* + + +*<_unitwage_2_> + gen byte unitwage_2 = . + label var unitwage_2 "Last wages' time unit secondary job 7 day recall" + label values unitwage_2 lblunitwage +* + + +*<_whours_2_> + gen whours_2 = . + label var whours_2 "Hours of work in last week secondary job 7 day recall" +* + + +*<_wmonths_2_> + gen wmonths_2 = . + label var wmonths_2 "Months of work in past 12 months secondary job 7 day recall" +* + + +*<_wage_total_2_> + gen wage_total_2 = . + label var wage_total_2 "Annualized total wage secondary job 7 day recall" +* + + +*<_firmsize_l_2_> +/* <_firmsize_l_2_note> + + Firm size of second job only available in first quarter (expanded + questionnaire) and not for employers + + */ + gen byte firmsize_l_2 = . + replace firmsize_l_2=1 if coe2_p7e==01 + replace firmsize_l_2=2 if coe2_p7e==02 + replace firmsize_l_2=6 if coe2_p7e==03 + replace firmsize_l_2=11 if coe2_p7e==04 + replace firmsize_l_2=16 if coe2_p7e==05 + replace firmsize_l_2=21 if coe2_p7e==06 + replace firmsize_l_2=31 if coe2_p7e==07 + replace firmsize_l_2=51 if coe2_p7e==08 + replace firmsize_l_2 = 101 if coe2_p7e==09 + replace firmsize_l_2 = 251 if coe2_p7e==10 + replace firmsize_l_2 = 501 if coe2_p7e==11 + replace firmsize_l_2 = . if mi(empstat_2) + label var firmsize_l_2 "Firm size (lower bracket) secondary job 7 day recall" +* + + +*<_firmsize_u_2_> + gen byte firmsize_u_2 = . + replace firmsize_u_2=1 if coe2_p7e==01 + replace firmsize_u_2=5 if coe2_p7e==02 + replace firmsize_u_2=10 if coe2_p7e==03 + replace firmsize_u_2=15 if coe2_p7e==04 + replace firmsize_u_2=20 if coe2_p7e==05 + replace firmsize_u_2=30 if coe2_p7e==06 + replace firmsize_u_2=50 if coe2_p7e==07 + replace firmsize_u_2=100 if coe2_p7e==08 + replace firmsize_u_2 = 250 if coe2_p7e==09 + replace firmsize_u_2 = 500 if coe2_p7e==10 + replace firmsize_u_2 = . if coe2_p7e==11 + replace firmsize_u_2 = . if mi(empstat_2) + label var firmsize_u_2 "Firm size (upper bracket) secondary job 7 day recall" +* + +} + +*----------8.4: 7 day reference additional jobs------------------------------* + +*<_t_hours_others_> + gen t_hours_others = . + label var t_hours_others "Annualized hours worked in all but primary and secondary jobs 7 day recall" +* + + +*<_t_wage_nocompen_others_> + gen t_wage_nocompen_others = . + label var t_wage_nocompen_others "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_others_> + gen t_wage_others = . + label var t_wage_others "Annualized wage in all but primary and secondary jobs (12-mon ref period)" +* + + +*----------8.5: 7 day reference total summary------------------------------* + + +*<_t_hours_total_> +/* approximate hours worked in a year 48 ILO standard */ + gen t_hours_total =(whours*4)*wmonths + label var t_hours_total "Annualized hours worked in all jobs 7 day recall" +* + + +*<_t_wage_nocompen_total_> + gen t_wage_nocompen_total = wage_total + label var t_wage_nocompen_total "Annualized wage in all jobs excl. bonuses, etc. 7 day recall" +* + + +*<_t_wage_total_> + gen t_wage_total = t_wage_nocompen_total + label var t_wage_total "Annualized total wage for all jobs 7 day recall" +* + + +*----------8.6: 12 month reference overall------------------------------* + +{ + +*<_lstatus_year_> + gen byte lstatus_year = . + replace lstatus_year=. if age < minlaborage & age != . + label var lstatus_year "Labor status during last year" + la de lbllstatus_year 1 "Employed" 2 "Unemployed" 3 "Non-LF" + label values lstatus_year lbllstatus_year +* + +*<_potential_lf_year_> + gen byte potential_lf_year = . + replace potential_lf_year=. if age < minlaborage & age != . + replace potential_lf_year = . if lstatus_year != 3 + label var potential_lf_year "Potential labour force status" + la de lblpotential_lf_year 0 "No" 1 "Yes" + label values potential_lf_year lblpotential_lf_year +* + + +*<_underemployment_year_> + gen byte underemployment_year = . + replace underemployment_year = . if age < minlaborage & age != . + replace underemployment_year = . if lstatus_year == 1 + label var underemployment_year "Underemployment status" + la de lblunderemployment_year 0 "No" 1 "Yes" + label values underemployment_year lblunderemployment_year +* + + +*<_nlfreason_year_> + gen byte nlfreason_year=. + label var nlfreason_year "Reason not in the labor force" + la de lblnlfreason_year 1 "Student" 2 "Housekeeper" 3 "Retired" 4 "Disable" 5 "Other" + label values nlfreason_year lblnlfreason_year +* + + +*<_unempldur_l_year_> + gen byte unempldur_l_year=. + label var unempldur_l_year "Unemployment duration (months) lower bracket" +* + + +*<_unempldur_u_year_> + gen byte unempldur_u_year=. + label var unempldur_u_year "Unemployment duration (months) upper bracket" +* + +} + +*----------8.7: 12 month reference main job------------------------------* + +{ + +*<_empstat_year_> + gen byte empstat_year = . + label var empstat_year "Employment status during past week primary job 12 month recall" + la de lblempstat_year 1 "Paid employee" 2 "Non-paid employee" 3 "Employer" 4 "Self-employed" 5 "Other, workers not classifiable by status" + label values empstat_year lblempstat_year +* + +*<_ocusec_year_> + gen byte ocusec_year = . + label var ocusec_year "Sector of activity primary job 12 day recall" + la de lblocusec_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_year lblocusec_year +* + +*<_industry_orig_year_> + gen industry_orig_year = . + label var industry_orig_year "Original industry record main job 12 month recall" +* + + +*<_industrycat_isic_year_> + gen industrycat_isic_year = . + label var industrycat_isic_year "ISIC code of primary job 12 month recall" +* + +*<_industrycat10_year_> + gen byte industrycat10_year = . + label var industrycat10_year "1 digit industry classification, primary job 12 month recall" + la de lblindustrycat10_year 1 "Agriculture" 2 "Mining" 3 "Manufacturing" 4 "Public utilities" 5 "Construction" 6 "Commerce" 7 "Transport and Comnunications" 8 "Financial and Business Services" 9 "Public Administration" 10 "Other Services, Unspecified" + label values industrycat10_year lblindustrycat10_year +* + + +*<_industrycat4_year_> + gen byte industrycat4_year=industrycat10_year + recode industrycat4_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_year "1 digit industry classification (Broad Economic Activities), primary job 12 month recall" + la de lblindustrycat4_year 1 "Agriculture" 2 "Industry" 3 "Services" 4 "Other" + label values industrycat4_year lblindustrycat4_year +* + + +*<_occup_orig_year_> + gen occup_orig_year = . + label var occup_orig_year "Original occupation record primary job 12 month recall" +* + + +*<_occup_isco_year_> + gen occup_isco_year = . + label var occup_isco_year "ISCO code of primary job 12 month recall" +* + + +*<_occup_skill_year_> + gen occup_skill_year = . + label var occup_skill_year "Skill based on ISCO standard primary job 12 month recall" +* + + +*<_occup_year_> + gen byte occup_year = . + label var occup_year "1 digit occupational classification, primary job 12 month recall" + la de lbloccup_year 1 "Managers" 2 "Professionals" 3 "Technicians" 4 "Clerks" 5 "Service and market sales workers" 6 "Skilled agricultural" 7 "Craft workers" 8 "Machine operators" 9 "Elementary occupations" 10 "Armed forces" 99 "Others" + label values occup_year lbloccup_year +* + + +*<_wage_no_compen_year_> + gen double wage_no_compen_year = . + label var wage_no_compen_year "Last wage payment primary job 12 month recall" +* + + +*<_unitwage_year_> + gen byte unitwage_year = . + label var unitwage_year "Last wages' time unit primary job 12 month recall" + la de lblunitwage_year 1 "Daily" 2 "Weekly" 3 "Every two weeks" 4 "Bimonthly" 5 "Monthly" 6 "Trimester" 7 "Biannual" 8 "Annually" 9 "Hourly" 10 "Other" + label values unitwage_year lblunitwage_year +* + + +*<_whours_year_> + gen whours_year = . + label var whours_year "Hours of work in last week primary job 12 month recall" +* + + +*<_wmonths_year_> + gen wmonths_year = . + label var wmonths_year "Months of work in past 12 months primary job 12 month recall" +* + + +*<_wage_total_year_> + gen wage_total_year = wage_total + label var wage_total_year "Annualized total wage primary job 12 month recall" +* + + +*<_contract_year_> + gen byte contract_year = . + label var contract_year "Employment has contract primary job 12 month recall" + la de lblcontract_year 0 "Without contract" 1 "With contract" + label values contract_year lblcontract_year +* + + +*<_healthins_year_> + gen byte healthins_year = . + label var healthins_year "Employment has health insurance primary job 12 month recall" + la de lblhealthins_year 0 "Without health insurance" 1 "With health insurance" + label values healthins_year lblhealthins_year +* + + +*<_socialsec_year_> + gen byte socialsec_year = . + label var socialsec_year "Employment has social security insurance primary job 7 day recall" + la de lblsocialsec_year 1 "With social security" 0 "Without social secturity" + label values socialsec_year lblsocialsec_year +* + + +*<_union_year_> + gen byte union_year = . + label var union_year "Union membership at primary job 12 month recall" + la de lblunion_year 0 "Not union member" 1 "Union member" + label values union_year lblunion_year +* + + +*<_firmsize_l_year_> + gen byte firmsize_l_year = . + label var firmsize_l_year "Firm size (lower bracket) primary job 12 month recall" +* + + +*<_firmsize_u_year_> + gen byte firmsize_u_year = . + label var firmsize_u_year "Firm size (upper bracket) primary job 12 month recall" +* + +} + + +*----------8.8: 12 month reference secondary job------------------------------* + +{ + +*<_empstat_2_year_> + gen byte empstat_2_year = . + label var empstat_2_year "Employment status during past week secondary job 12 month recall" + label values empstat_2_year lblempstat_year +* + + +*<_ocusec_2_year_> + gen byte ocusec_2_year = . + label var ocusec_2_year "Sector of activity secondary job 12 day recall" + la de lblocusec_2_year 1 "Public Sector, Central Government, Army" 2 "Private, NGO" 3 "State owned" 4 "Public or State-owned, but cannot distinguish" + label values ocusec_2_year lblocusec_2_year +* + + + +*<_industry_orig_2_year_> + gen industry_orig_2_year = . + label var industry_orig_2_year "Original survey industry code, secondary job 12 month recall" +* + + + +*<_industrycat_isic_2_year_> + gen industrycat_isic_2_year = . + label var industrycat_isic_2_year "ISIC code of secondary job 12 month recall" +* + + +*<_industrycat10_2_year_> + gen byte industrycat10_2_year = . + label var industrycat10_2_year "1 digit industry classification, secondary job 12 month recall" + label values industrycat10_2_year lblindustrycat10_year +* + + +*<_industrycat4_2_year_> + gen byte industrycat4_2_year=industrycat10_2_year + recode industrycat4_2_year (1=1)(2 3 4 5 =2)(6 7 8 9=3)(10=4) + label var industrycat4_2_year "1 digit industry classification (Broad Economic Activities), secondary job 12 month recall" + label values industrycat4_2_year lblindustrycat4_year +* + + +*<_occup_orig_2_year_> + gen occup_orig_2_year = . + label var occup_orig_2_year "Original occupation record secondary job 12 month recall" +* + + +*<_occup_isco_2_year_> + gen occup_isco_2_year = . + label var occup_isco_2_year "ISCO code of secondary job 12 month recall" +* + + +*<_occup_skill_2_year_> + gen occup_skill_2_year = . + label var occup_skill_2_year "Skill based on ISCO standard secondary job 12 month recall" +* + + +*<_occup_2_year_> + gen byte occup_2_year = . + label var occup_2_year "1 digit occupational classification, secondary job 12 month recall" + label values occup_2_year lbloccup_year +* + + +*<_wage_no_compen_2_year_> + gen double wage_no_compen_2_year = . + label var wage_no_compen_2_year "Last wage payment secondary job 12 month recall" +* + + +*<_unitwage_2_year_> + gen byte unitwage_2_year = . + label var unitwage_2_year "Last wages' time unit secondary job 12 month recall" + label values unitwage_2_year lblunitwage_year +* + + +*<_whours_2_year_> + gen whours_2_year = . + label var whours_2_year "Hours of work in last week secondary job 12 month recall" +* + + +*<_wmonths_2_year_> + gen wmonths_2_year = . + label var wmonths_2_year "Months of work in past 12 months secondary job 12 month recall" +* + + +*<_wage_total_2_year_> + gen wage_total_2_year = . + label var wage_total_2_year "Annualized total wage secondary job 12 month recall" +* + +*<_firmsize_l_2_year_> + gen byte firmsize_l_2_year = . + label var firmsize_l_2_year "Firm size (lower bracket) secondary job 12 month recall" +* + + +*<_firmsize_u_2_year_> + gen byte firmsize_u_2_year = . + label var firmsize_u_2_year "Firm size (upper bracket) secondary job 12 month recall" +* + +} + + +*----------8.9: 12 month reference additional jobs------------------------------* + + +*<_t_hours_others_year_> + gen t_hours_others_year = . + label var t_hours_others_year "Annualized hours worked in all but primary and secondary jobs 12 month recall" +* + +*<_t_wage_nocompen_others_year_> + gen t_wage_nocompen_others_year = . + label var t_wage_nocompen_others_year "Annualized wage in all but primary & secondary jobs excl. bonuses, etc. 12 month recall)" +* + +*<_t_wage_others_year_> + gen t_wage_others_year = . + label var t_wage_others_year "Annualized wage in all but primary and secondary jobs 12 month recall" +* + + +*----------8.10: 12 month total summary------------------------------* + + +*<_t_hours_total_year_> + gen t_hours_total_year = . + label var t_hours_total_year "Annualized hours worked in all jobs 12 month month recall" +* + + +*<_t_wage_nocompen_total_year_> + gen t_wage_nocompen_total_year = wage_total + label var t_wage_nocompen_total_year "Annualized wage in all jobs excl. bonuses, etc. 12 month recall" +* + + +*<_t_wage_total_year_> + gen t_wage_total_year = wage_total + label var t_wage_total_year "Annualized total wage for all jobs 12 month recall" +* + + +*----------8.11: Overall across reference periods------------------------------* + + +*<_njobs_> + gen njobs = sdem_t_tra + replace njobs = 1 if njobs == 0 & lstatus == 1 + replace njobs = . if lstatus != 1 + label var njobs "Total number of jobs" +* + + +*<_t_hours_annual_> + gen t_hours_annual = t_hours_total + label var t_hours_annual "Total hours worked in all jobs in the previous 12 months" +* + + +*<_linc_nc_> + gen linc_nc = wage_total + label var linc_nc "Total annual wage income in all jobs, excl. bonuses, etc." +* + + +*<_laborincome_> + gen laborincome = wage_total + label var laborincome "Total annual individual labor income in all jobs, incl. bonuses, etc." +* + + + +*----------8.13: Labour cleanup------------------------------* + +{ +*<_% Correction min age_> + +** Drop info for cases under the age for which questions to be asked (do not need a variable for this) + local lab_var "minlaborage lstatus nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome" + + foreach v of local lab_var { + cap confirm numeric variable `v' + if _rc == 0 { // is indeed numeric + replace `v'=. if ( age < minlaborage & !missing(age) ) + } + else { // is not + replace `v'= "" if ( age < minlaborage & !missing(age) ) + } + + } + +* +} + + +/*%%============================================================================================= + 9: Final steps +==============================================================================================%%*/ + +quietly{ + +*<_% KEEP VARIABLES - ALL_> + + keep countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% ORDER VARIABLES_> + + order countrycode survname survey icls_v isced_version isco_version isic_version year vermast veralt harmonization int_year int_month hhid pid weight weight_m weight_q psu strata wave panel visit_no type_of_interview urban subnatid1 subnatid2 subnatid3 subnatidsurvey subnatid1_prev subnatid2_prev subnatid3_prev gaul_adm1_code gaul_adm2_code gaul_adm3_code hsize age male relationharm relationcs marital eye_dsablty hear_dsablty walk_dsablty conc_dsord slfcre_dsablty comm_dsablty migrated_mod_age migrated_ref_time migrated_binary migrated_years migrated_from_urban migrated_from_cat migrated_from_code migrated_from_country migrated_reason ed_mod_age school literacy educy educat7 educat5 educat4 educat_orig educat_isced vocational vocational_type vocational_length_l vocational_length_u vocational_field_orig vocational_financed minlaborage lstatus potential_lf underemployment nlfreason unempldur_l unempldur_u empstat ocusec industry_orig industrycat_isic industrycat10 industrycat4 occup_orig occup_isco occup_skill occup wage_no_compen unitwage whours wmonths wage_total contract healthins socialsec union firmsize_l firmsize_u empstat_2 ocusec_2 industry_orig_2 industrycat_isic_2 industrycat10_2 industrycat4_2 occup_orig_2 occup_isco_2 occup_skill_2 occup_2 wage_no_compen_2 unitwage_2 whours_2 wmonths_2 wage_total_2 firmsize_l_2 firmsize_u_2 t_hours_others t_wage_nocompen_others t_wage_others t_hours_total t_wage_nocompen_total t_wage_total lstatus_year potential_lf_year underemployment_year nlfreason_year unempldur_l_year unempldur_u_year empstat_year ocusec_year industry_orig_year industrycat_isic_year industrycat10_year industrycat4_year occup_orig_year occup_isco_year occup_skill_year occup_year wage_no_compen_year unitwage_year whours_year wmonths_year wage_total_year contract_year healthins_year socialsec_year union_year firmsize_l_year firmsize_u_year empstat_2_year ocusec_2_year industry_orig_2_year industrycat_isic_2_year industrycat10_2_year industrycat4_2_year occup_orig_2_year occup_isco_2_year occup_skill_2_year occup_2_year wage_no_compen_2_year unitwage_2_year whours_2_year wmonths_2_year wage_total_2_year firmsize_l_2_year firmsize_u_2_year t_hours_others_year t_wage_nocompen_others_year t_wage_others_year t_hours_total_year t_wage_nocompen_total_year t_wage_total_year njobs t_hours_annual linc_nc laborincome + +* + +*<_% DROP UNUSED LABELS_> + + * Store all labels in data + label dir + local all_lab `r(names)' + + * Store all variables with a label, extract value label names + local used_lab = "" + ds, has(vallabel) + + local labelled_vars `r(varlist)' + + foreach varName of local labelled_vars { + local y : value label `varName' + local used_lab `"`used_lab' `y'"' + } + + * Compare lists, `notused' is list of labels in directory but not used in final variables + local notused : list all_lab - used_lab // local `notused' defines value labs not in remaining vars + local notused_len : list sizeof notused // store size of local + + * drop labels if the length of the notused vector is 1 or greater, otherwise nothing to drop + if `notused_len' >= 1 { + label drop `notused' + } + else { + di "There are no unused labels to drop. No value labels dropped." + } + + +* + +} + + +*<_% DELETE MISSING VARIABLES_> + +quietly: describe, varlist +local kept_vars `r(varlist)' + +foreach var of local kept_vars { + capture assert missing(`var') + if !_rc drop `var' +} + +* + + +*<_% COMPRESS_> + +compress + +* + + +*<_% SAVE_> + +save "`path_output'/`out_file'", replace + +* diff --git a/Support/B - Country Survey Details/MEX/ENOE/1. Introduction to ENOE.md b/Support/B - Country Survey Details/MEX/ENOE/1. Introduction to ENOE.md index 54a3289c8..4cef83076 100644 --- a/Support/B - Country Survey Details/MEX/ENOE/1. Introduction to ENOE.md +++ b/Support/B - Country Survey Details/MEX/ENOE/1. Introduction to ENOE.md @@ -10,40 +10,44 @@ Introduction to the Mexican Labour Force Survey (ENOE) ## What is the MEX ENOE? -The Mexican Labour Force and Unemployment Survey (ENOE) is the Mexican Labour Force Survey run as part of Mexico’s National Surveys series from 2005 to 2020. +The Mexican Labour Force and Unemployment Survey (ENOE) is the Mexican Labour Force Survey run as part of Mexico’s National Surveys series from 2005 to 2023. The survey ran as "new ENOE" (ENOE-N) from Q3 2020 to 2022 due to the CoVid-19 Pandemic (see details below). ## What does the MEX ENOE cover? -The Mexican ENOE is a labour force survey collecting information on demographic details (age, sex, location), education (academic), social security, labour market activities over the past quarter, as well as time use and activities over the previous 7 days. The years and sample size of ENOE harmonized for GLD are: - -| Year | # of Individuals | # of Households | -| :------- | :-------- | :-------- | -| 2005 | 1,649,291 | 126,481 -| 2006 | 1,663,902 | 127,784 -| 2007 | 1,643,644 | 127,562 -| 2008 | 1,619,352 | 126,713 -| 2009 | 1,590,077 | 125,773 -| 2010 | 1,593,114 | 126,092 -| 2011 | 1,574,013 | 125,882 -| 2012 | 1,563,171 | 125,780 -| 2013 | 1,552,325 | 179,943 -| 2014 | 1,590,748 | 126,799 -| 2015 | 1,579,514 | 126,985 -| 2016 | 1,548,185 | 127,381 -| 2017 | 1,543,995 | 129,937 -| 2018 | 1,535,217 | 129,158 -| 2019 | 1,590,785 | 134,522 -| 2020 | 1,142,227 | 132,788 +The Mexican ENOE is a labour force survey collecting information on demographic details (age, sex, location), education (academic), social security, labour market activities over the past quarter, as well as time use and activities over the previous 7 days. The years and sample size of ENOE(-N) harmonized for GLD are: + +| Year | Survey type | # of Households | # of Individuals | # of Observations | +| :------- | :-------- | :-------- | :-------- | :-------- | +| 2005 | ENOE | 126,488 | 564,061 | 1,649,542 | +| 2006 | ENOE | 127,788 | 562,800 | 1,664,008 | +| 2007 | ENOE | 127,566 | 556,767 | 1,643,760 | +| 2008 | ENOE | 126,719 | 550,495 | 1,619,532 | +| 2009 | ENOE | 125,779 | 542,328 | 1,590,193 | +| 2010 | ENOE | 126,099 | 541,856 | 1,593,239 | +| 2011 | ENOE | 125,888 | 536,283 | 1,574,197 | +| 2012 | ENOE | 125,785 | 531,803 | 1,563,375 | +| 2013 | ENOE | 179,964 | 682,182 | 1,552,567 | +| 2014 | ENOE | 126,802 | 535,298 | 1,590,927 | +| 2015 | ENOE | 126,994 | 531,375 | 1,579,632 | +| 2016 | ENOE | 127,383 | 525,881 | 1,548,364 | +| 2017 | ENOE | 129,946 | 530,317 | 1,544,167 | +| 2018 | ENOE | 129,176 | 524,787 | 1,535,415 | +| 2019 | ENOE | 134,545 | 542,014 | 1,591,056 | +| 2020 | ENOE | 116,367 | 409,268 | 409,268 | +| 2020 | ENOE-N | 113,649 | 406,679 | 641,607 | +| 2021 | ENOE-N | 157,660 | 604,797 | 1,565,332 | +| 2022 | ENOE-N | 141,252 | 546,271 | 1,574,939 | +| 2023 | ENOE | 163,116 | 613,576 | 1,700,438 | Note that the ENOE is a panel survey where households are visited up to five times, explaining the low number of households for the sample size. ## Where can the data be found? -The microdata is free and publicly available on the National Institute of Statistics and Geography (INEGI). INEGI created a [dedicated website](https://www.inegi.org.mx/programas/enoe/15ymas/#Microdatos) that records ENOE and all previous versions, besides it contains complete information to understand the framework of the ENOE. Data from 2019 onwards can only be circulated within the World Bank. For further information kindly get in touch with the World Bank Jobs Group. +The microdata is free and publicly available on the National Institute of Statistics and Geography (INEGI). INEGI created a [dedicated website](https://www.inegi.org.mx/programas/enoe/15ymas/#Microdatos) that records ENOE. ## What is the sampling procedure? -The ENOE uses a stratified two-stage design. The introductory section of ENOE provides ample detail on the breakdown and goals of the process. Below we share a sequence of images that will allow the user to access the information in the ENOE webpage. The text is in Spanish. Yet, we did a short summary in english at the bottom of this section to give the user a general idea of the information. +The ENOE uses a stratified two-stage design. The introductory section of ENOE provides ample detail on the breakdown and goals of the process. Below we share a sequence of images that will allow the user to access the information in the ENOE webpage. The text is in Spanish. Yet, we did a short summary in English at the bottom of this section to give the user a general idea of the information. Image 1. Steps to find the information in the webpage @@ -55,7 +59,7 @@ Image 1. Steps to find the information in the webpage

![](utilities/ENOE_intro3.png)

-Reference: Screenshots from ENOE- INEGI webapage. Further details in *Encuesta Nacional de Ocupación y Empleo* under the ["recent version"](https://www.inegi.org.mx/programas/enoe/15ymas/) +Reference: Screenshots from ENOE- INEGI webpage. Further details in *Encuesta Nacional de Ocupación y Empleo* under the ["recent version"](https://www.inegi.org.mx/programas/enoe/15ymas/) [Summarized Translation from the original version] @@ -66,7 +70,7 @@ Reference: Screenshots from ENOE- INEGI webapage. Further details in *Encuesta N Sampling unit: The private home. Analysis unit: The home and the residents of the dwelling. [...] - Sampling frame : The sampling frame used for the ENOE is INEGI's 2012 National Housing Framework, built from the cartographic and demographic information obtained during the 2010 Population and Housing Census, which is updated with each new census survey. [...] + Sampling frame: The sampling frame used for the ENOE is INEGI's 2012 National Housing Framework, built from the cartographic and demographic information obtained during the 2010 Population and Housing Census, which is updated with each new census survey. [...] ## What is the geographic significance level? @@ -82,71 +86,51 @@ However, in [2016 the name changed officially](https://dof.gob.mx/nota_detalle.p ### Evolution of the ENOE questionnaires -In the past fifteen years, the Mexican national statistics institute -(INEGI) published five updates (Table 1) of the labor force questionnaire or -ENOE. The ENOE has two versions: the extended version and the basic -version. Every quarter, the INEGI conducts labor surveys using either -version. +Over the years, the Mexican national statistics institute (INEGI) published a series of updates to the questionnaires. The changes are at times introduced from one quarter to the next within a year. The precise details can be seen on the [INEGI website](https://www.inegi.org.mx/programas/enoe/15ymas/#documentacion) under the drop-down menu "Cuestionarios" (Questionnaires). -Figure 1. Type of questionnaire used in ENOE -

-![](utilities/ENOEversions.png) -

-Note.- Image taken from ["Conociendo la base de datos de la ENOE"](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/con_basedatos_proy2010.pdf) by INEGI +### Effect of the CoVid Pandemic -Table 1. ENOE questionnaire revision by year +The CoVid 19 Pandemic interrupted regular surveys procedure. The data for 2020 was only collected as expected in the first quarter of 2020. -| Year | Version Q1 | -| ------------ | ----------------------------------------------------------------------------------------------------- | -| 2005 to 2006 | [First Extended Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_amp_v1.pdf) | -| 2007 | [First Basic Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_bas_v1.pdf) | -| 2008 | [Second Basic Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_bas_v2.pdf) | -| 2009 | [Second Extended Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_amp_v2.pdf) | -| 2010 to 2012 | [Third Extended Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_amp_v3.pdf) | -| 2013 to 2015 | [Fourth Extended Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_amp_v4.pdf) | -| 2016 to 2020 | [Fifth Extended Version](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/c_amp_v5.pdf) | +From the third trimester of 2020 to the fourth trimester of 2022 INEGI operated a different survey (called ENOE_N) that contained a smaller sample size and a larger reliance on phone interviews. -— [Author made. based on ENOE -Questionnaires](https://www.inegi.org.mx/programas/enoe/15ymas/) +The data is available on the INEGI website but is not used in GLD. From the first trimester of 2023 the ENOE continued as before with some small methodological changes. The latest methodological note can be found [here](https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/nueva_estruc/889463909743.pdf). -### Effect of the CoVid Pandemic +### Classifications of industry and occupation used in ENOE and ENOE-N -The CoVid 19 Pandemic interrupted regular surveys procedure. The data for 2020 was only collected as expected in the first quarter of 2020. Data thereafter must be used with precaution. +In the Mexican National Survey of Occupation and Employment (Encuesta Nacional de Ocupación y Empleo - ENOE) as well as then "New" ENOE (ENOE-N) following the years immediately after the pandemic (2020 Q3 to 2022 Q4) uses national classifications to code the industry and occupation of workers. -From the third trimester of 2020 to the fourth trimester of 2022 INEGI operated a different survey (called ENOE_N) that contained a smaller sample size and a larger reliance on phone interviews. - -The data is available on the INEGI website but is not used in GLD. From the first trimester of 2023 the ENOE continued (largely) as before. +#### Overview of industry codes used in ENOE(-N) -### Coding of industry and occupation codes +The below table shows the classifications used at different points in time in the ENOE survey to code the industry workers are in. -The ENOE codes occupation based on the "Mexican Classification of Occupations" (Clasificación Mexicana de Ocupaciones - CMO) from 2005 to 2012 and from 2013 to 2020 on the "National System of Classification of Occupations" (Sistema Nacional de Clasificación de Ocupaciones - SINCO). These are mapped to ISCO-08. +| From | To | Survey | Version Used | Notes | +| -------- | ------- | ------ | -------------| --------------------------------------------- | +| Q1 2005 | Q2 2012 | ENOE | SCIAN 04 | | +| Q3 2005 | Q4 2022 | ENOE | SCIAN 07 | ENOE de facto not run from Q2 2020 to Q4 2022 | +| Q3 2020 | Q2 2021 | ENOE-N | SCIAN 07 | | +| Q3 2021 | Q4 2022 | ENOE-N | SCIAN 18 | | +| Q1 2023 | Current | ENOE | SCIAN 18 | | -On the industry side, ENOE codifies industry over the years based on four different versions of the North American System of Industrial Classification (Sistema de Clasificación Industrial de América del Norte - SCIAN), namely the 2007 versions, all data is mapped to ISIC-4. +The classification document (see [example here](https://www.inegi.org.mx/contenidos/programas/enoe/15ymas/doc/clasificaciones_enoe.pdf)) states that these versions are reduced versions of the actual SCIAN versions (i.e., with less detail) as respondents will not be able to describe their industries with total accuracy. These classifications contain about 180 unique codes. The precise details of the mapping can be found [here on separate document](Correspondence_NAICS_ISIC.md) -The table below provides an overview of the different versions underlying the survey as well as what version they have been mapped to. The precise details of how the mapping was done is covered [here in a separate document on occupations](Correspondence_occup_ISCO.md) as well as [here on industry classification](Correspondence_NAICS_ISIC.md). +#### Overview of occupation codes used in ENOE(-N) -| Year of survey | National occup version | ISCO version | National industry version | ISIC version | -| :----: | :----: | :----: | :----: | :----: | -| 2005 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2006 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2007 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2008 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2009 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2010 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2011 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2012 | CMO | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2013 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2014 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2015 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2016 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2017 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2018 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2019 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | -| 2020 | SINCO 2011 | ISCO-08 | SCIAN 2007 | ISIC-4 | +The below table shows the classifications used at different points in time in the ENOE survey to code the occupation workers hold. -### Relevant information from INEGI on the ISIC codes used by ENOE +| From | To | Survey | Version Used | Notes | +| -------- | ------- | ------ | -------------| --------------------------------------------- | +| Q1 2005 | Q2 2012 | ENOE | CMO (09?) | Exact version of CMO unknown | +| Q3 2005 | Q4 2022 | ENOE | SINCO 11 | ENOE de facto not run from Q2 2020 to Q4 2022 | +| Q3 2020 | Q2 2021 | ENOE-N | SINCO 11 | | +| Q3 2021 | Q4 2022 | ENOE-N | SINCO 19 | | +| Q1 2023 | Current | ENOE | SINCO 19 | | -Please check the following [document](https://github.com/worldbank/gld/blob/1ff9697fbfe571a1b95c6d10c4f8ce5e0d6a7568/Support/B%20-%20Country%20Survey%20Details/MEX/ENOE/utilities/Comentario%20aplicado%20a%20la%20versi%C3%B3n%202(spa-eng).pdf) to get more insight on the ENOE SCIAN codes and the meaning of the digits used in the raw data. +The classification breakdown for the first surveys (2005 to Q2 2012) is listed as CMO-09. The GLD team expects that another systems must have been used prior (i.e., using CMO-2009 in 2005) but could not ascertain the details. We expect (hope) any CMO version prior to CMO-09 is not significantly different from it. The precise details of the mapping can be found [here on separate document](Correspondence_occup_ISCO.md) Further information or questions about the microdata in this webpage can be directed to [World Bank GLD Focal Point](mailto:gld@worldbank.org). + +### ENOE Panel + +The ENOE survey revisits households over five consecutive quarters (with a longer period for individuals on phone surveys since CoVid-19). The GLD team has created code to generate a single file out of the individual harmonized files with unique panel identifiers. You may find the codes [here](). diff --git a/Support/B - Country Survey Details/MEX/ENOE/Correspondence_NAICS_ISIC.md b/Support/B - Country Survey Details/MEX/ENOE/Correspondence_NAICS_ISIC.md index a32ef7e3e..5598719e3 100644 --- a/Support/B - Country Survey Details/MEX/ENOE/Correspondence_NAICS_ISIC.md +++ b/Support/B - Country Survey Details/MEX/ENOE/Correspondence_NAICS_ISIC.md @@ -1,135 +1,27 @@ -# Correspondence between NAICS Mexico and ISIC +# Correspondence of Mexican Industry Classification to International Codes -Information regarding the industry respondents are employed in is coded in the Encuesta Nacional de Ocupación y Empleo (ENOE) using the codes of the [North American Industry Classification System](http://en.www.inegi.org.mx/app/scian/) (shortened as NAICS in English and SCIAN in Spanish). +## Overview of industry codes used in ENOE(-N) -This document first describes the logic of the process and then provides users with the underlying conversions tables, conversion algorithms, as well as the generated `dta` files used in the harmonization codes. +The below table shows the classifications used at different points in time in the ENOE(-N) surveys to code the industry workers are in. -## Data as present in survey raw data +| From | To | Survey | Version Used | Notes | +| -------- | ------- | ------ | -------------| --------------------------------------------- | +| Q1 2005 | Q2 2012 | ENOE | SCIAN 04 | | +| Q3 2005 | Q4 2022 | ENOE | SCIAN 07 | ENOE de facto not run from Q2 2020 to Q4 2022 | +| Q3 2020 | Q2 2021 | ENOE-N | SCIAN 07 | | +| Q3 2021 | Q4 2022 | ENOE-N | SCIAN 18 | | +| Q1 2023 | Current | ENOE | SCIAN 18 | | -The image below shows the answers to the relevant question (`p4a1` asks for the industry the company the respondent works for is in) for the dataset from the first quarter of 2005: +## Detail of classification -

-![SCIAN ENOE example](utilities/intro_p4a.PNG) -

+The SCIAN (NAICS in the English acronym) is a detailed system of organising industry shared by Mexico, the United Stated of America, and Canada. It reaches six levels of (six digits) of aggregation, going from broad categories to narrow niches. Given that the survey only uses people's descriptions of their work and transforms these into codes, the Mexican statistical offices (INEGI) chose to use a reduced, idiosyncratic classification system (of around 180 distinct codes). -All years from 2005 to 2020 (in the first quarter) use the 2007 SCIAN version and in all year `p4a` is a four-digit code while SCIAN is a six-digit code. However, the information contained is actually only useable at three digits, as the ENOE coding uses the three digits (to the level of subsector) and uses the fourth digit not to designate the next level (industry group) but rather is a subsector disaggregation not in line with SCIAN, as the email below from the Mexican Statistics Institute INEGI shows (in Spanish). +## Source of information -

-![SCIAN ENOE example](utilities/SCIAN_Email_INEGI.png) -

+The codes used for SCIAN 07 and SCIAN 18 are available online on the INEGI website. Users can find it [here](https://www.inegi.org.mx/programas/enoe/15ymas/#documentacion) under the drop down menu option "Clasificadores" (Classifiers). -## Correspondance information available +We have, moreover, received comparison tables between [Scian 2004 and 2007](utilities/Tabla%20comparativa%20SCIAN-2004%20y%202007.xlsx) and between [SCIAN 2007 and 2018](utilities/Tabla%20comparativa%20SCIAN%202007%20-%202018.xlsx) from INEGI after reaching out to the (very helpful) team in Mexico. -INEGI has [website dedicated to NAICS](https://www.inegi.org.mx/app/scian/) where it stores general information in the classificaiton and - most importantly for concordance purposes - comparative tables between the different SCIAN versions and the different ISCO versions. The image below shows the available comparisons in March 2022: +## Processing of information -

-![SCIAN available options](utilities/scian_options.png) -

- -The information is available as both a PDF and an Excel File. The image below shows the first lines of the first sheet of the 2007 to ISIC 4 Excel document: - -

-![SCIAN Excel example](utilities/scian_07_example_xlsx.PNG) -

- -Note how the first sheet contains the SCIAN to ISIC mapping, while the second sheet maps the inverse relation. Note further that SCIAN codes are all at 6 digit level in the comparison tables provided by the National Statistics Office (NSO) while the ISIC codes are just at 4 digits. - -The last piece of information to understand before proceeding with creating a mapping `.dta` that can be used in the harmonization is the fact that mapping is not perfect in the correspondence tables provided by the NSO. In the above image this is the case (e.g., 111121 maps to 0111) but this is not always so. The image below shows how SCIAN code 111410 maps to five (!) different and distinct ISIC codes. - -

-![SCIAN Imperfect Matching](utilities/scian_imperfect_match.png) -

- -## Creating a map between NAICS and ISIC - -### Overall mapping logic - -The overall mapping is done in two steps. The first step is to create an `R` code that reads in the Excel file from the NSO, cleans it (note in the image how there are empty lines between two SCIAN codes) and equates three-digit SCIAN codes (since information in ENOE is useable at three-digits, as per the email) to an ISIC code. The code generates a `.dta` file that lists all possible unique SCIAN codes and provides the corresponding ISIC code. - -The second step is to use the `.dta` created in the first step in the harmonization. That is to merge in the correspondance table when harmonizing and use matched ISIC codes to generate the GLD `industrycat_isic` variable. - -### Generating the `R` code and resulting `.dta` file - -The mapping of NAICS to ISIC codes is performed by a user written `R` code. It reads from the relevant NSO correpsondence Excel file stored under `MEX_[YYYY]_ENOE\MEX_[YYYY]_ENOE_v01_M\Doc` and writes the comparison `.dta` file merged in the harmonization under `MEX_[YYYY]_ENOE\MEX_[YYYY]_ENOE_v[##]_M\Data\Stata`. The corresponding `R` itself is stored under `MEX_[YYYY]_ENOE\MEX_[YYYY]_ENOE_v[##]_M\Programs`. Note that the actual files are stored on a World Bank server - the conversion files are, however, availabe [in the utilities folder here](utilities/Additional%20Data). - -The first step in the process is to reduce the NSO correspondece six-digit system to the three digits covered in the ENOE. This creates duplicates as the, for example, 14 codes between `461110` and `46122` that can be reduced to the three-digit `461` maps to 27 distinct ISIC codes. There are 94 unique three-digit codes in SCIAN 2007. - -The second step is to compare the correspondence of SCIAN three-digit codes to ISIC three-digit codes and count the number of total cases and the number of matches to each code. The image below shows this process for some of the first codes: - -

-![SCIAN Reducation Logic](utilities/match_1.png) -

- -In the above image the aforementioned code `461` has a total of 27 mappings, one of which starts with ISIC code `471`, and 13 cases each start with `472` and `478`. In the case of SCIAN `462` all three cases map directly to ISIC `471` (red box in the above image). In the case of SCIAN `464` the seven total cases are much more spread out (orange box in the above image). - -At this stage of the algorithm, only perfect matches are map from three-digit SCIAN codes to three-digit ISIC codes. This applies to 17 of the 94 unique SCIAN three-digit codes, leaving 77 yet to map. - -The third step matches each three-digit NAICS code to the reduced two-digit ISIC equivalent. This is exemplified in the snapshot below: - -

-![SCIAN Reducation Logic](utilities/match_2.png) -

- -In the case of SCIAN `464` (blue box in the above image) the mapping is now at 100%, meaning that all seven ISIC codes start with codes `47`. In the case of SCIAN `468` (orange box in the above image), the options are more evenly split even though there is a majority option. In the case of the SCIAN `222` each of the four ISIC codes has the same number of mappings - no clear assignment can be made. - -At this third step assignments SCIAN to ISIC two-digits are made if there is a single option with >50% cases assigned to it. In the case above SCIAN `468` would not be assigned at this stage. This is because there may be two mappings with each 50.0% each, which would lead to a non-unique assignment. This logic maps a further 60 unique codes, leaving 17 codes still to match. - -The fourth step looks at all steps without an absolute majority. This step itself involves two sub-steps. This is best illustrated looking at the codes for SCIAN `222`, `487`, and `551` below. - -

-![SCIAN Reducation Logic](utilities/match_3.png) -

- -The overall idea at this step is to select a mapping based on simple majority – and chose randomly in the case of a tie. For code `487` this is mapping to ISIC code `49` as this is the mapping category in 3 out of 7 possible mappings (sum the number of possible mappings denoted in column `n`). - -For `222` there is no single best category, but, if we look at the Sections the codes belong to – the top level ISIC aggregations – two of the codes are section `E` (Water supply; sewerage, waste management and remediation activities) while each one is from section `D` (Electricity, gas, steam, and air conditioning supply) and `H` (Transportation and storage). When selecting a mapping this sectional relevance should be taken into account to reduce any potential randomness in the mapping. - -Thus, the first sub-step is to assign the ISIC two-digit codes to their sections and see if there is a single section where a single value has at least 50% of the mappings. This is the case for SCIAN `222`, where section `E` represents 50% of the mappings. For SCIAN `551`, each possible mapping has a 50% weight and thus no sub-selection can be made. For SCIAN `487` the selection is even stronger as 6 out of the 7 mappings are from section `H`. The possible mapping choices are hence reduced to the following: - -

-![SCIAN Reducation Logic](utilities/match_4.png) -

- -At the second sub-step, within each SCIAN code the simple majority is selected. This allows a unique mapping of 13 of the remaining 17 codes. In just four cases (such as `222` and `551`) a random selection is made between equally likely mappings – in three of the four cases (such as `551` the selection is between codes of different ISIC sections). - -### Merging the correspondence with the survey data - -The data is merged in the harmonization at the first stage of database assembly (see individual harmonization codes). In the case of the 2017 ENOE there are 167,033 individuals for which the survey has an industry SCIAN codes. The correspondence process is able to match to 162,374 of those (97.2%). The image below shows the quality of the matches made: - -

-![SCIAN Reducation Logic](utilities/merge_hist_17_cumul_w.png) -

- -The graph depicts weighted cumulative distribution by match quality. It shows that only 10% of all observations have a match quality of 47% or worse (green circle), while 80% have a quality of 77% or higher (blue circle). Two thirds of all cases have a quality of 90% or better (red circle). - -## Caveats and extensions - -### Caveat - What the mapping does and does not do - -Overall, the quality of the mapping seems to be very good. However, the metric used to evaluate matching quality, while sensible, contains potential pitfalls. The most obvious one is that it is evaluating importance of a map by number of existing codes and not relevance of the codes. As an example, see the following excerpt from NAICS: - -| NAICS Code | NAICS Description | ISIC Code | -| :------------ | :-------------------------------: | --------: | -| 312131 | Grape alcoholic drinks | 1101 | -| 312132 | Pulque (fermented agave) | 1102 | -| 312139 | Cider & other fermented drinks | 1102 | -| 312141 | Rum & sugar cane drinks | 1101 | -| 312142 | Distilled agave drinks | 1101 | - - -The way the correspondence has proceeded, it treats every entry equally. However, given that tequila, probably the economically most important drink in Mexico is made from agave, NAICS code `312142` should be weighted more strongly in this context. If we think of Cuba, code `312141` should probably be more important. This information, however, is not avaialable to us. Furthermore, note that the process of matching less than perfectly at only the lowest level of ISIC solves the issue here. All these NAICS codes starting with `3121` don't match to ISIC at four digits but do so perfectly to `110`. - -In this case no problem has arisen and as small niches grow, they can be expected to obtain more codes (as clothing grows, groups are created for shirts, trousers, ...) so it can be assumed that a single category is not significantly larger than any other category in the economy, but it still should be kept in mind that the evaluation of the mapping is based only on the number of categories, regardless of the economic relevance. - -### Extension - What you may add if you would be available - -A further extension, which may help in creating better matches is to use the text descriptions, provided in the NSO correspondence document, which define in more detail what the NAICS and ISIC codes cover. This is beyond our current capacity, though. If you, dear Reader, think you may be able to support this, please contact the team here on GitHub. We really would appreciate any help! - -## Underlying data for emulating process -The harmonization codes merge in `dta` files created from the correspondence tables shown above using the algorithmic logic described in this document. In particular we use: - -- [The correspondence table between SCIAN 07 and ISIC 4](utilities/SCIAN_07_ISIC_4.xlsx); - -- [The `R` code to map SCIAN 07 to ISIC 4](utilities/SCIAN_07_3D_ISIC_4.R); - -- [The `dta` file with codes for SCIAN 07 and ISIC 4](utilities/SCIAN_07_3D_ISIC_4.dta); +The correspondence tables where converted into separate files for each SCIAN version. Then the codes were manually recoded to the 4th revision of ISIC. The individual files are avaiable for [SCIAN 04](utilities/ENOE_SCIAN_2004_Codes.xslx), [SCIAN 07](utilities/ENOE_SCIAN_2007_Codes.xslx), and [SCIAN 18](utilities/ENOE_SCIAN_2018_Codes.xslx). These are converted into `.dta` files using Stata do files ([for 2004](utilities/Convert_SCIAN_04_ISIC_4_to_dta.do), [for 2007](utilities/Convert_SCIAN_07_ISIC_4_to_dta.do), and [for 2018](utilities/Convert_SCIAN_18_ISIC_4_to_dta.do)). The `.dta` files are also made available ([for 2004](utilities/SCIAN_04_ISIC_4.dta), [2007](utilities/SCIAN_07_ISIC_4.dta), and [2018](utilities/SCIAN_18_ISIC_4.dta)). \ No newline at end of file diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_04_ISIC_4_to_dta.do b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_04_ISIC_4_to_dta.do new file mode 100644 index 000000000..868b5124a --- /dev/null +++ b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_04_ISIC_4_to_dta.do @@ -0,0 +1,17 @@ + +*========================================================================* +* Code to convert the manual correspondence in the SCIAN 2007 spreadsheet +*========================================================================* + +* Define paths +local spreadsheet_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Input/ENOE_SCIAN_2004_Codes.xlsx" +local output_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Output/SCIAN_04_ISIC_4.dta" + +* Import file +import excel "`spreadsheet_path'", sheet("Manual correspondences") cellrange(A7:F186) firstrow clear + +* Rename variables, keep only relevant, save +rename (Clave Code) (scian isic) +keep scian isic +destring scian, replace +save "`output_path'", replace \ No newline at end of file diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_07_ISIC_4_to_dta.do b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_07_ISIC_4_to_dta.do new file mode 100644 index 000000000..519281d29 --- /dev/null +++ b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_07_ISIC_4_to_dta.do @@ -0,0 +1,17 @@ + +*========================================================================* +* Code to convert the manual correspondence in the SCIAN 2007 spreadsheet +*========================================================================* + +* Define paths +local spreadsheet_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Input/ENOE_SCIAN_2007_Codes.xlsx" +local output_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Output/SCIAN_07_ISIC_4.dta" + +* Import file +import excel "`spreadsheet_path'", sheet("Manual correspondences") cellrange(A7:F185) firstrow clear + +* Rename variables, keep only relevant, save +rename (Clave Code) (scian isic) +keep scian isic +destring scian, replace +save "`output_path'", replace \ No newline at end of file diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_18_ISIC_4_to_dta.do b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_18_ISIC_4_to_dta.do new file mode 100644 index 000000000..67ca33d31 --- /dev/null +++ b/Support/B - Country Survey Details/MEX/ENOE/utilities/Convert_SCIAN_18_ISIC_4_to_dta.do @@ -0,0 +1,17 @@ + +*========================================================================* +* Code to convert the manual correspondence in the SCIAN 2018 spreadsheet +*========================================================================* + +* Define paths +local spreadsheet_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Input/ENOE_SCIAN_2018_Codes.xlsx" +local output_path "Y:/GLD-Harmonization/529026_MG/Countries/MEX/SCIAN codes/Output/SCIAN_18_ISIC_4.dta" + +* Import file +import excel "`spreadsheet_path'", sheet("Manual correspondences") cellrange(A7:F190) firstrow clear + +* Rename variables, keep only relevant, save +rename (Clave Code) (scian isic) +keep scian isic +destring scian, replace +save "`output_path'", replace \ No newline at end of file diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2004_Codes.xlsx b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2004_Codes.xlsx new file mode 100644 index 000000000..aec42c333 Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2004_Codes.xlsx differ diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2007_Codes.xlsx b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2007_Codes.xlsx new file mode 100644 index 000000000..0a7b09866 Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2007_Codes.xlsx differ diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2018_Codes.xlsx b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2018_Codes.xlsx new file mode 100644 index 000000000..4f5cc6d21 Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/ENOE_SCIAN_2018_Codes.xlsx differ diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_04_ISIC_4.dta b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_04_ISIC_4.dta new file mode 100644 index 000000000..3e301c701 Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_04_ISIC_4.dta differ diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_07_ISIC_4.dta b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_07_ISIC_4.dta new file mode 100644 index 000000000..1b73c840d Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_07_ISIC_4.dta differ diff --git a/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_18_ISIC_4.dta b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_18_ISIC_4.dta new file mode 100644 index 000000000..e5b11a8f1 Binary files /dev/null and b/Support/B - Country Survey Details/MEX/ENOE/utilities/SCIAN_18_ISIC_4.dta differ