From 53b413dfcebbdd60309aeda5e4455a128970394b Mon Sep 17 00:00:00 2001 From: atomes-epar <62309202+atomes-epar@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:07:29 -0700 Subject: [PATCH] Initial commit for updated ETH W4 file (#246) * Currency conversion update * Alignment with W5 and all plots update --- .../EPAR_UW_335_Ethiopia_ESS_W4.do | 5086 +++++++++++++---- 1 file changed, 3918 insertions(+), 1168 deletions(-) diff --git a/Ethiopia ESS/Ethiopia ESS Wave 4/EPAR_UW_335_Ethiopia_ESS_W4.do b/Ethiopia ESS/Ethiopia ESS Wave 4/EPAR_UW_335_Ethiopia_ESS_W4.do index 8a4172a..b81b5a6 100644 --- a/Ethiopia ESS/Ethiopia ESS Wave 4/EPAR_UW_335_Ethiopia_ESS_W4.do +++ b/Ethiopia ESS/Ethiopia ESS Wave 4/EPAR_UW_335_Ethiopia_ESS_W4.do @@ -4,12 +4,12 @@ for the construction of a set of agricultural development indicators using the Ethiopia Socioeconomic Survey (ESS) LSMS-ISA Wave 4 (2018-19) *Author(s) : Didier Alia, Andrew Tomes, & C. Leigh Anderson - *Acknowledgments: We acknowledge the helpful contributions of David Coomes, Kelsey Figone, Helen Ippolito, Jack Knauer, Josh Merfeld, Isabella Sun, Rebecca Toole, Emma Weaver, Ayala Wineman, Pierre Biscaye, Travis Reynolds and members of the World Bank's LSMS-ISA team, the FAO's RuLIS team, IFPRI, IRRI, and the Bill & Melinda Gates Foundation Agricultural Development Data and Policy team in discussing indicator construction decisions. All coding errors remain ours alone. -*Date : This Version - 03 Feb 2023 +*Date : This Version - 16 July 2024 +*Dataset Version : ETH_2018_ESS_v02_M_Stata ----------------------------------------------------------------------------------------------------------------------------------------------------*/ *Data source @@ -61,11 +61,11 @@ set maxvar 10000 ssc install findname // need this user-written ado file for some commands to work *Set location of raw data and output -global directory "//netid.washington.edu/wfs/EvansEPAR/Project/EPAR/Working Files/335 - Ag Team Data Support/Waves" -*global directory "/Volumes/wfs/Project/EPAR/Working Files/335 - Ag Team Data Support/Waves" +global directory "335_Agricultural-Indicator-Data-Curation" //Update this to match your local repo location *Set directories global Ethiopia_ESS_W4_raw_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 4/Raw DTA Files" +global Ethiopia_ESS_W4_temp_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 4/Final Dta Files/temp_data" global Ethiopia_ESS_W4_created_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 4/Final DTA Files/created_data" global Ethiopia_ESS_W4_final_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 4/Final DTA Files/final_data" @@ -74,12 +74,9 @@ global Ethiopia_ESS_W4_final_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 4/ *EXCHANGE RATE AND INFLATION FOR CONVERSION IN USD IDS ******************************************************************************** global Ethiopia_ESS_W4_exchange_rate 21.2389 /*39.3988*/ // https://www.bloomberg.com/quote/USDETB:CUR -global Ethiopia_ESS_W4_gdp_ppp_dollar 8.668 /*10.35*/ // https://data.worldbank.org/indicator/PA.NUS.PPP -global Ethiopia_ESS_W4_cons_ppp_dollar 8.674 /*10.74*/ // https://data.worldbank.org/indicator/PA.NUS.PRVT.PP -/*DYA.7.27.2021 These should the 2016 values and we then use the inflation rate to bring every monetary value in 2016 values before converting into PPP or USD -it this note that some of these values has slightly changed since the last time we use them*/ -global Ethiopia_ESS_W4_inflation -.20628477 // /*DYA.7.27.2021*/ Inflation between 2019 and 2016 di (218.586-275.396)/275.396 - +global Ethiopia_ESS_W4_gdp_ppp_dollar /*8.668*/ 8.5209 // https://data.worldbank.org/indicator/PA.NUS.PPP +global Ethiopia_ESS_W4_cons_ppp_dollar /*8.674*/ 8.4964 // https://data.worldbank.org/indicator/PA.NUS.PRVT.PP +global Ethiopia_ESS_W4_inflation 1.31848 // //ALT Updated 07.09.24: 2019/2017 = 322.5/244.6 ******************************************************************************** *THRESHOLDS FOR WINSORIZATION ******************************************************************************** @@ -89,36 +86,213 @@ global wins_upper_thres 99 // Threshold for winzorization at the top of t *Note Re-scaling survey weights to match population estimates *https://databank.worldbank.org/source/world-development-indicators# for 2019 (most recent year) -global Ethiopia_ESS_W4_pop_tot 112078730 -global Ethiopia_ESS_W4_pop_rur 88542197 //79% of total -global Ethiopia_ESS_W4_pop_urb 23536533 //21% of total +global Ethiopia_ESS_W4_pop_tot 111129438 +global Ethiopia_ESS_W4_pop_rur 88055633 //79% of total +global Ethiopia_ESS_W4_pop_urb 23073805 //21% of total ******************************************************************************** *GLOBALS OF PRIORITY CROPS //change these globals if you are interested in different crops ******************************************************************************** ////Limit crop names in variables to 6 characters or the variable names will be too long! - -global topcropname_area "maize rice wheat sorgum millet grdnt beans swtptt cassav banana teff barley coffee sesame hsbean nueg" -global topcrop_area "2 5 8 6 3 24 12 62 10 42 7 1 72 27 13 25" -global comma_topcrop_area "2, 5, 8, 6, 3, 24, 12, 62, 10, 42, 7, 1, 72, 27, 13, 25" -global topcropname_full "maize rice wheat sorghum millet groundnut beans sweetpotato cassava banana teff barley coffee sesame horsebean nueg" +global topcropname_area "teff maize wheat sorgum coffee barley enset hsbean millet rice soy nueg banana swtptt tomato onion mango avocad" // teff - hsbean are in the top 10 by area, other crops are of additional interest +global topcrop_area "7 2 8 6 72 1 74 13 3 5 18 25 42 62 63 58 46 84" +global comma_topcrop_area "7, 2, 8, 6, 72, 1, 74, 13, 3, 5, 18, 25, 42, 62, 63, 58, 46, 84" +global topcropname_full "teff maize wheat sorghum coffee barley enset horsebeans millet rice soybeans nueg banana sweetpotato tomato onion mango avocado" global nb_topcrops : word count $topcrop_area +/* MGM 5.18.2024 (W5): keeping this here for reference - these are the ATA specific crops of interest - added these to the globals above +*ATA Top Crops +global topcropname_ata "barley maize teff wheat tomato onion banana mango avocad" +global topcrop_ata "1 2 7 8 63 58 42 46 84" +global comma_topcrop_ata "1, 2, 7, 8, 63, 58, 42, 46, 84" +global topcropname_full_ata "barley maize teff wheat tomato onion banana mango avocado" +global nb_topcrops_ata : word count $topcrop_ata +*/ + +set obs $nb_topcrops //Update if number of crops changes +egen rnum = seq(), f(1) t($nb_topcrops) +gen crop_code = . +gen crop_name = "" +forvalues k=1(1)$nb_topcrops { + local c : word `k' of $topcrop_area + local cn : word `k' of $topcropname_area + replace crop_code = `c' if rnum==`k' + replace crop_name = "`cn'" if rnum==`k' +} +drop rnum +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropname_table.dta", replace +//ALT: From W5 ******************************************************************************** -* CROP CONVERSION FACTOR ADJUSTMENT +* UNIQUELY IDENTIFIABLE GEOGRAPHIES AND PLOTS - note that without this code, collapsing by [zone, woreda, kebele, ea] ALONE (as we do to get median prices) will result in inaccurate medians. We need to create unique identifiers to collapse on! +* UNIQUELY IDENTIFIABLE PARCELS AND FIELDS AT THE HOUSEHOLD LEVEL (for AqQuery+) + +* To create uniquely identified variables: +* Comment the below section in +* Create a "temp_data" folder in the "Final DTA Files" folder in 335 +* Create a Global for temp_data (e.g. global Ethiopia_ESS_W4_temp_data "$directory/Ethiopia ESS/Ethiopia ESS Wave 5/Final DTA Files/temp_data") +* Run the code below +* Comment this section back out - only need to run once! +* Change all "${Ethiopia_ESS_W4_temp_data}/file.dta" to "${Ethiopia_ESS_W4_temp_data}/file.dta" so that you now use the amended file rather than the original raw file. ******************************************************************************** -// W4 raw data file Crop_CF_Wave4.dta has duplicate observations for crop_code=74, unit_cd=62. Based on W3 data, we have chosen to retain cf=4.34 (and drop cf=6.125) for continuity. -use "$Ethiopia_ESS_W4_raw_data/Food and Crop Conversion Factors/Crop_CF_Wave4.dta", clear -drop if crop_code==74 & unit_cd==62 & mean_cf_nat==6.125 -save "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", replace +capture confirm file "$Ethiopia_ESS_W4_temp_data/sect_cover_pp_w4.dta" //Simple check for an output file; this block only needed one time, so code will only run the code if it's missing from the temp_data folder. Delete it to make the code re-run. +if(_rc){ +local directory_raw $Ethiopia_ESS_W4_raw_data +local directory_temp $Ethiopia_ESS_W4_temp_data + +local raw_files : dir "`directory_raw'" files "*.dta", respectcase + +foreach file of local raw_files { + use "`directory_raw'/`file'", clear + + + // REGION + capture confirm variable saq01 + if(!_rc) { + tostring saq01, gen(region) + replace region = "0" + region if length(region) == 1 + } + + + // ZONE + capture confirm variable saq02 + if(!_rc) { + tostring saq02, replace + egen zone = concat(region saq02) + drop region // We just used this variable to create a unique string for zone - now we prefer saq01 (region in byte form) + assert zone != "" if saq02 != "" + drop saq02 + rename zone saq02 + lab var saq02 "Zone" + order saq01 saq02 + } + + // WOREDA + capture confirm variable saq03 + if(!_rc) { + tostring saq03, replace + egen woreda = concat(saq02 saq03) // Just need saq02 and 03 because 02 was already concat. with saq01 + assert woreda != "" if saq03 != "" + drop saq03 + rename woreda saq03 + lab var saq03 "Woreda" + order saq01 saq02 saq03 + } + + // CITY + capture confirm variable saq04 + if(!_rc) { + tostring saq04, replace + replace saq04 = "0" + saq04 if length(saq04) == 1 + egen city = concat(saq03 saq04) + assert city != "" if saq04 != "" + drop saq04 + rename city saq04 + lab var saq04 "City" + order saq01 saq02 saq03 saq04 + } + + // SUBCITY + capture confirm variable saq05 + if(!_rc) { + tostring saq05, replace + replace saq05 = "0" + saq05 if length(saq05) == 1 + egen subcity = concat(saq04 saq05) + assert subcity != "" if saq05 != "" + drop saq05 + rename subcity saq05 + lab var saq05 "Sub City" + order saq01 saq02 saq03 saq04 saq05 + } + + // KEBELE + capture confirm variable saq06 + if(!_rc) { + tostring saq06, replace + egen kebele = concat(saq05 saq06) // Adding in city and subcity just so it matches how household_id and holder_id are stylized + assert kebele != "" if saq06 != "" + drop saq06 + rename kebele saq06 + lab var saq06 "Kebele" + order saq01 saq02 saq03 saq04 saq05 saq06 + } + + // EA + capture confirm variable saq07 + if(!_rc) { + tostring saq07, replace + egen ea = concat(saq06 saq07) + assert ea != "" if saq07 != "" + drop saq07 + rename ea saq07 + lab var saq07 "Enumeration Area" + // destring saq01 saq02 saq03 saq04 saq05 saq06 saq07, replace + order saq01 saq02 saq03 saq04 saq05 saq06 saq07 + } + + + + // PARCEL_ID - creating a unique parcel identifier + capture confirm variable saq09 + if(!_rc) { + capture confirm variable parcel_id + if(!_rc) { + tostring saq09, replace + tostring parcel_id, replace + egen parcel_id_2 = concat(saq09 parcel_id) + assert parcel_id_2 != "" if parcel_id != "" + drop parcel_id + rename parcel_id_2 parcel_id + lab var parcel_id "Unique Parcel ID" + order saq01 saq02 saq03 saq04 saq05 saq06 saq07 household_id holder_id parcel_id + } + } + + // FIELD_ID - creating a unique field identifier + capture confirm variable parcel_id + if(!_rc) { + capture confirm variable field_id + if(!_rc) { + tostring field_id, replace + egen field_id_2 = concat(parcel_id field_id) + assert field_id_2 != "" if field_id != "" + drop field_id + rename field_id_2 field_id + lab var field_id "Unique Field ID" + //order saq01 saq02 saq03 saq04 saq05 saq06 saq07 saq08 saq09 household_id holder_id parcel_id field_id + } + } + save "`directory_temp'/`file'", replace +} +} +* One additional file needs to get modified. Note that this file does not exist in the WB W5 download. EPAR borrowed the land unit conversion factor file from previous ESS waves. We provided this file on GitHub for download and ease of convenience. This should get added to the raw data folder! (see directory globals above) + +use "${Ethiopia_ESS_W4_raw_data}/ET_local_area_unit_conversion.dta", clear +tostring region, g(region2) +tostring zone, replace +tostring woreda, replace +replace region2 = "0"+region2 if length(region2)==1 +replace zone = "0"+zone if length(zone)==1 +replace woreda = "0"+woreda if length(woreda)==1 +egen zone2 = concat(region zone) +egen woreda2 = concat(zone woreda) + +drop region2 zone woreda +ren *2 * +save "${Ethiopia_ESS_W4_temp_data}/ET_local_area_unit_conversion.dta", replace +******************************************************************************** +* POVERTY THRESHOLD CALCULATION - FT +******************************************************************************** +global Ethiopia_ESS_W4_poverty_190 (1.90*5.574746609)*322.5198/133.25 //Inflation since 2011 using the 2011 PPP dollar +global Ethiopia_ESS_W4_poverty_npl 7184 * $Ethiopia_ESS_W4_inflation // National poverty line from Mekasha and Tarp for 2016. We assume it's adjusted for inflation. +global Ethiopia_ESS_W4_poverty_215 (2.15*$Ethiopia_ESS_W4_cons_ppp_dollar)*$Ethiopia_ESS_W4_inflation // CPI2019/CPI2017 ******************************************************************************** *HOUSEHOLD IDS ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Household/sect_cover_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect_cover_hh_W4.dta", clear ren saq01 region ren saq02 zone ren saq03 woreda @@ -140,7 +314,7 @@ keep region zone woreda city subcity kebele ea household weight rural household_ ta rural //--> 46.01% ta rural [aw=weight] //--> 67.54% more in line with W3 */ -destring region zone woreda, replace +//destring region zone woreda, replace save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", replace @@ -148,7 +322,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", replace ******************************************************************************** *WEIGHTS AND GENDER OF HEAD ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Household/sect1_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_hh_W4.dta", clear gen fhh = s1q02==2 if s1q01==1 *Unlike W3 we do not need to change the strata significantly, as all regions and urban/rural stratification are representative (see BID for more information). Remember, W4 is an entirely new sample. @@ -175,7 +349,7 @@ replace stratum_id=24 if rural==0 & saq01==13 //Harar, urban replace stratum_id=25 if rural==0 & saq01==14 //Addis Ababa, urban KEF 2.4.21: Addis Ababa is only urban, no rural respondents replace stratum_id=26 if rural==0 & saq01==15 //Dire Dawa, urban replace strataid=stratum_id if rural==0 //assign new strata IDs to urban respondents, stratified by region and urban - +drop if s1q05==2 //DYA limiting this to only individual still in the households gen hh_members = 1 gen hh_women = s1q02==2 gen hh_adult_women = (hh_women==1 & s1q03a>14 & s1q03a<65) //Adult women from 15-64 (inclusive) @@ -209,30 +383,39 @@ egen weight_pop_rururb=rowtotal(weight_pop_rur weight_pop_urb) total hh_members [pweight=weight_pop_rururb] lab var weight_pop_rururb "Survey weight - adjusted to match rural and urban population" drop weight_pop_rur weight_pop_urb -destring region zone woreda, replace +//destring region zone woreda, replace save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_male_head.dta", replace +keep region zone woreda subcity kebele ea household weight_pop_rururb +merge 1:1 region zone woreda subcity kebele ea household using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" +keep region zone woreda subcity kebele ea household rural weight weight_pop_rururb household_id +gen hhid = household_id //ALT: Lazy fix; future edits should standardize this. +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", replace + ******************************************************************************** * INDIVIDUAL IDS * ******************************************************************************** +*DYA 7.3.2023 /; This should have been the household roster and not the post-planting files *KEF Added this section per Andrew's guidance. Needed to make a person_id file that was comparable to NGA and TZA. 1/11/22 -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect1_pp_w4.dta", clear -keep household_id s1q00 s1q02 s1q03 -gen female = s1q03 == 2 // No missings. +*use "$Ethiopia_ESS_W4_temp_data/sect1_pp_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_hh_w4.dta", clear +keep household_id individual_id s1q02 s1q03a +gen female = s1q02 == 2 // No missings. lab var female "1 = individual is female" -rename s1q00 indiv -rename s1q03 sex -rename s1q02 age +rename individual_id indiv +rename s1q02 sex +rename s1q03a age +gen personid=indiv save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_person_ids.dta", replace -******************************************************************************** +********************************************************************************* *INDIVIDUAL GENDER ******************************************************************************** *Using gender from planting and harvesting *Harvest -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect1_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_ph_W4.dta", clear ren s1q00 personid gen female_ph = s1q03==2 // NOTE: Assuming missings are MALE replace female_ph =. if s1q03==. @@ -241,7 +424,7 @@ duplicates drop household_id personid, force save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_ph.dta", replace *Planting -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect1_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_pp_W4.dta", clear ren s1q00 personid gen female_pp = s1q03==2 // NOTE: Assuming missings are MALE replace female_pp =. if s1q03==. @@ -256,7 +439,7 @@ replace female=female_ph if female_pp==. save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", replace *Using household roster for missing gender -use "$Ethiopia_ESS_W4_raw_data/Household/sect1_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_hh_W4.dta", clear ren individual_id personid //NOTE: s1q00 is the name of the HH member in this file. Therefore, we are using individual_id here since it correlates to the household member ID that hh_s1q00 references in W3. *ren household_id hhid //Keeping this as household_id use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", clear @@ -271,107 +454,125 @@ lab var individual_id "Individual ID" duplicates drop individual_id, force save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", replace + + ******************************************************************************** *PLOT DECISION-MAKERS ******************************************************************************** *Gender/age variables -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear gen cultivated = s3q03==1 // if plot was cultivated - -*First owner/decision maker -gen personid = s3q13 -merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", gen(dm1_merge) keep(1 3) -*5,964 not matched from master -*13,375 matched -tab dm1_merge cultivate // All but two unmatched observations are due to field not being cultivated -*First decision-maker variables -gen dm1_female = female -drop female personid -*Second owner/decision maker -gen personid = s3q15_1 -merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", gen(dm2_merge) keep(1 3) -*10,027 not matched from master -*9,312 matched -gen dm2_female = female -drop female personid -*Third owner/decision maker -gen personid = s3q15_2 -merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", gen(dm3_merge) keep(1 3) -*16,617 not matched from master -*2,722 matched -gen dm3_female = female -drop female personid -*Constructing three-part gendered decision-maker variable; male only (=1) female only (=2) or mixed (=3) -gen dm_gender = 1 if (dm1_female==0 | dm1_female==.) & (dm2_female==0 | dm2_female==.) & (dm3_female==0 | dm3_female==.) & !(dm1_female==. & dm2_female==. & dm3_female==.) -replace dm_gender = 2 if (dm1_female==1 | dm1_female==.) & (dm2_female==1 | dm2_female==.) & (dm3_female==1 | dm3_female==.) & !(dm1_female==. & dm2_female==. & dm3_female==.) -replace dm_gender = 3 if dm_gender==. & !(dm1_female==. & dm2_female==. & dm3_female==.) +gen personid1 = s3q13 +gen personid2 = s3q15_1 +gen personid3 = s3q15_2 +//keep if cultivated == 1 +keep household_id personid* parcel_id field_id holder_id cultivated +reshape long personid, i(household_id parcel_id field_id holder_id cultivated) j(dm_no) +gen dm_ID = personid if dm_no == personid +drop if personid==. +merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", gen(dm1_merge) keep(1 3) +collapse (mean) female (firstnm) dm_ID, by(household_id parcel_id field_id holder_id cultivated) +gen dm_gender = 1 if female==0 +replace dm_gender = 2 if female==1 +replace dm_gender = 3 if dm_gender==. & female!=. la def dm_gender 1 "Male only" 2 "Female only" 3 "Mixed gender" la val dm_gender dm_gender lab var dm_gender "Gender of decision-maker(s)" -keep dm_gender holder_id household_id field_id parcel_id +keep dm_gender holder_id household_id field_id parcel_id dm_ID cultivated // FJT 7.25.23 save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_gender_dm.dta", replace +//ALT QUICK FIX -UPDATE REST OF CODE +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers.dta", replace + +*DYA 7.3.2023: Adding this here to create a single file containing individuals who are plot manager_female* +******************************************************************************** +*INDIVUAL ENGAGEMENT IN ECONOMIC ACTIVITIES (plot manager, business owner, business manager, livestock keep, nonagwage_worker, agwage_worker) +******************************************************************************** +* Plot managers +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear +gen plot_manager_1=s3q13 +gen plot_manager_2=s3q15_1 +gen plot_manager_3=s3q15_2 +gen cultivated = s3q03==1 +drop if cultivated==0 // drop non cultivated field +forvalue j=1(1)3 { + preserve + keep household_id parcel_id field_id plot_manager_`j' + drop if plot_manager_`j'==. | plot_manager_`j'==0 // from observations with no reported manager + gen field_managed=1 + collapse (sum) field_managed, by(household_id plot_manager_`j') + ren plot_manager_`j' plot_manager_id + tempfile plot_manager_`j' + save `plot_manager_`j'' + restore +} + +use `plot_manager_1', clear +append using `plot_manager_2' +append using `plot_manager_3' +collapse(sum) field_managed, by(household_id plot_manager) +drop field_managed +gen farm_manager=1 +ren plot_manager personid +gen dm_ID= personid // FJT 7.25.23 +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plotmager.dta", replace + + + ******************************************************************************** * ALL AREA CONSTRUCTION ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -gen cultivated = s3q03==1 // if plot was cultivated +use "${Ethiopia_ESS_W4_temp_data}/sect3_pp_w4.dta", clear +ren household_id hhid +gen cultivated = s3q03==1 // if plot was cultivated *Generating some conversion factors -gen area = s3q02a +gen area = s3q02a gen local_unit = s3q02b gen area_sqmeters_gps = s3q08 replace area_sqmeters_gps = . if area_sqmeters_gps<0 *Constructing geographic medians for local unit per square meter ratios preserve -*ren household_id hhid // Keeping this as household_id -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" // 4,651 not matched, 18,699 matched -// BET 08.06.2021 this leaves us with all rural households -drop if _merge==2 // 4,011 obs deleted -drop _merge -gen sqmeters_per_unit = area_sqmeters_gps/area // 101 missing vars generated -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region zone local_unit) -ren sqmeters_per_unit sqmeters_per_unit_zone -ren observations obs_zone -destring region zone, replace -lab var sqmeters_per_unit_zone "Square meters per local unit (median value for this region and zone)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", replace + keep hhid holder_id parcel_id field_id area local_unit area_sqmeters_gps // Joaquin 04.04.23: Added holder_id + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" + drop if _merge==2 + drop _merge + gen sqmeters_per_unit = area_sqmeters_gps/area + gen observations = 1 + collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region zone local_unit) + ren sqmeters_per_unit sqmeters_per_unit_zone + ren observations obs_zone + lab var sqmeters_per_unit_zone "Square meters per local unit (median value for this region and zone)" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", replace restore preserve -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -*ren household_id hhid // keeping this as household_id -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" -drop if _merge==2 -drop _merge -gen sqmeters_per_unit = area_sqmeters_gps/area -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region local_unit) -ren sqmeters_per_unit sqmeters_per_unit_region -ren observations obs_region -destring region, replace -lab var sqmeters_per_unit_region "Square meters per local unit (median value for this region)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", replace + replace area_sqmeters_gps=. if area_sqmeters_gps<0 + keep hhid parcel_id field_id area local_unit area_sqmeters_gps + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" + drop if _merge==2 + drop _merge + gen sqmeters_per_unit = area_sqmeters_gps/area + gen observations = 1 + collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region local_unit) + ren sqmeters_per_unit sqmeters_per_unit_region + ren observations obs_region + lab var sqmeters_per_unit_region "Square meters per local unit (median value for this region)" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", replace restore preserve -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -*ren household_id hhid // Keeping this as household_id -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" -drop if _merge==2 -drop _merge -gen sqmeters_per_unit = area_sqmeters_gps/area -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (local_unit) -ren sqmeters_per_unit sqmeters_per_unit_country -ren observations obs_country -lab var sqmeters_per_unit_country "Square meters per local unit (median value for the country)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", replace + replace area_sqmeters_gps=. if area_sqmeters_gps<0 + keep hhid parcel_id field_id area local_unit area_sqmeters_gps + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" + drop if _merge==2 + drop _merge + gen sqmeters_per_unit = area_sqmeters_gps/area + gen observations = 1 + collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (local_unit) + ren sqmeters_per_unit sqmeters_per_unit_country + ren observations obs_country + lab var sqmeters_per_unit_country "Square meters per local unit (median value for the country)" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", replace restore - - *Now creating area - starting with sq meters gen area_meas_hectares = s3q02a*10000 if s3q02b==1 // hectares to sq m replace area_meas_hectares = s3q02a if s3q02b==2 // already in sq m @@ -380,11 +581,13 @@ replace area_meas_hectares = s3q02a if s3q02b==2 // already in sq m gen region = saq01 gen zone = saq02 gen woreda = saq03 -destring region zone woreda, replace -merge m:1 region zone woreda local_unit using "$Ethiopia_ESS_W4_raw_data/Land Area Conversion Factor/ET_local_area_unit_conversion.dta", gen(conversion_merge) keep(1 3) // 195 not matched from using, dropped -*16,983 not matched from master -*2,356 matched -replace area_meas_hectares = s3q02a*conversion if !inlist(s3q02b,1,2) & s3q02b!=. // non-traditional units +//ALT TEMP FIX - FIGURE OUT WHY REGION IS NUMERIC +//tostring region, replace +//replace region = "0" + region if saq01 < 10 +merge m:1 region zone woreda local_unit using "$Ethiopia_ESS_W4_temp_data/ET_local_area_unit_conversion.dta", gen(conversion_merge) keep(1 3) // 66 not matched from using, dropped +*20,826 not matched from master +*12,479 matched +replace area_meas_hectares = s3q02a*conversion if !inlist(s3q02b,1,2) & s3q02a!=. // non-traditional units *Field area is currently farmer reported - replacing with GPS area when available replace area_meas_hectares = s3q08 if s3q08!=. & s3q08>0 // 32,205 changes replace area_meas_hectares = area_meas_hectares*0.0001 // Changing back into hectares @@ -398,96 +601,518 @@ replace area_meas_hectares = (area*(sqmeters_per_unit_country/10000)) if local_u count if area!=. & area_meas_hectares==. replace area_meas_hectares = 0 if area_meas_hectares == . lab var area_meas_hectares "Field area measured in hectares, with missing obs imputed using local median per-unit values" -merge 1:1 holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_gender_dm.dta", nogen +merge 1:1 holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers.dta", nogen gen area_meas_hectares_male = area_meas_hectares if dm_gender==1 gen area_meas_hectares_female = area_meas_hectares if dm_gender==2 gen area_meas_hectares_mixed = area_meas_hectares if dm_gender==3 + +gen agland = (s3q03==1 | s3q03==2 | s3q03==3 | s3q03==5) // Cultivated, prepared for Belg season, pasture, or fallow. Excludes forest and "other" (which seems to include rented-out) + +bysort holder_id hhid parcel_id field_id: gen dup = cond(_N==1,0,_n) +tab dup +//collapse (max) agland cultivated area_meas_hectares*, by(holder_id household_id2 parcel_id field_id) // added 1.20.22 +keep hhid holder_id parcel_id field_id agland cultivated area_meas_hectares* /*pp_s3q10a pp_s3q10b pp_s3q10c_a pp_s3q10c_b*/ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", replace +use "${Ethiopia_ESS_W4_temp_data}/sect3_pp_w4.dta", clear +ren household_id hhid +ren saq01 region +ren saq02 zone +ren saq03 woreda +gen cultivated = s3q03==1 // if plot was cultivated +*Generating some conversion factors +gen area = s3q02a +gen local_unit = s3q02b +lab val local_unit s3q02b +ren s3q2b_os local_unit_os + +* Backfilling o/s units +replace local_unit=2 if strpos(local_unit_os, "METER") // 4 real changes +replace local_unit=4 if strpos(local_unit_os, "BOY") // 4 real changes +replace local_unit=12 if strpos(local_unit_os, "KADA") // 160 real changes - MGM 5.21.2024: adding this as a unit code. We have >10 observations at the country level that self report this unit AND do not have GPS measurements! +//MGM 4.1.2024: Note to go back and backfill o/s local units? 781 observations total (KADA n=160, PUR n=138, GAFA n=83, KIND n=81, among others) +gen gps_meas = 1 if s3q07<3 // includes if measured using handheld GPS or android app +replace gps_meas = 0 if s3q07==3 +gen area_sqmeters_gps = s3q08 +replace area_sqmeters_gps = . if area_sqmeters_gps<0 // MGM 4.1.2024: 0 changes -/**** +*Constructing geographic medians for local unit per square meter ratios +preserve +keep hhid parcel_id field_id area local_unit area_sqmeters_gps +merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", keep (1 3) nogen //MGM 4.1.2024: 97 not matched +gen sqmeters_per_unit = area_sqmeters_gps/area // 136 missing vars generated +gen observations = 1 +collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region zone local_unit) +ren sqmeters_per_unit sqmeters_per_unit_zone +ren observations obs_zone +lab var sqmeters_per_unit_zone "Square meters per local unit (median value for this region and zone)" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", replace //MGM 4.1.2024: observational values and summary stats of measured GPS sq meters seems to be normal with no weird outliers +restore -*KEF 5.20.21 The following code is a holdover from W4. In W4, 98/19,339 observations are measured with GPS or compass and rope in sq. m., so the following conversions from local units is no longer necessary. -/*Now creating area - starting with sq meters -gen area_meas_hectares = s3q02a*10000 if s3q02b==1 // hectares to sq m -replace area_meas_hectares = s3q02a if s3q02b==2 // those fields already in sq m -/*For rest of units, we need to use the conversion factors -gen region = saq01 -gen zone = saq02 -gen woreda = saq03 -merge m:1 region zone woreda local_unit using "$Ethiopia_ESS_W4_raw_data/Land Area Conversion Factor/ET_local_area_unit_conversion.dta", gen(conversion_merge) keep(1 3) // KEF 5.2.21 This is giving me an error because this .dta file does not exist in the raw .dta files. It is not a created .dta file and the next time it is in the file is in line 1765. Looking into the BIDs between waves 3 and 4, it seems that in the previous wave there was some self-reporting of land size/area; not all land was GPS-measured. In this wave, enumerator measured all fields using gps or compass if the field were small. It seems that none of the areas were self-reported by the holder. -/*66 not matched from using, dropped -*20,826 not matched from master -*12,479 matched*/ -replace area_meas_hectares = s3q02a*conversion if !inlist(s3q02b,1,2) & s3q02b!=. //KEF 5.2.21 This does not run; conversion not found. non-traditional units -*/ -replace area_meas_hectares = s3q08 if s3q08!=. & s3q08>0 // 18,529 changes -replace area_meas_hectares = area_meas_hectares*0.0001 // Changing back into hectares -*/ +preserve +replace area_sqmeters_gps=. if area_sqmeters_gps<0 +keep hhid parcel_id field_id area local_unit area_sqmeters_gps +merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", keep(1 3) nogen //MGM 4.1.2024: 97 not matched, 14,781 matched +gen sqmeters_per_unit = area_sqmeters_gps/area +gen observations = 1 +collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region local_unit) +ren sqmeters_per_unit sqmeters_per_unit_region +ren observations obs_region +lab var sqmeters_per_unit_region "Square meters per local unit (median value for this region)" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", replace +restore -*Creating new code to convert area from square meters to hectares. -gen area_meas_hectares = s3q08/10000 +preserve +replace area_sqmeters_gps=. if area_sqmeters_gps<0 +keep hhid parcel_id field_id area local_unit area_sqmeters_gps +merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", keep(1 3) nogen //MGM 4.1.2024: 97 not matched, 14,781 matched +gen sqmeters_per_unit = area_sqmeters_gps/area +gen observations = 1 +collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (local_unit) +ren sqmeters_per_unit sqmeters_per_unit_country +ren observations obs_country +lab var sqmeters_per_unit_country "Square meters per local unit (median value for the country)" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", replace +restore -*Using our own created conversion factors for still missing observations -ren saq01 region -ren saq02 zone +*Area Measured Hectares - restricted to that which was collected by a GPS measurement +gen area_meas_hectares = s3q08/10000 // measured sq meters divided by 10,000 + +ren area reported_area +merge m:1 region zone woreda local_unit using "$Ethiopia_ESS_W4_temp_data/ET_local_area_unit_conversion.dta", gen(conversion_merge) keep(1 3) +*13,312 not matched from master +*1,566 matched + +* Field Size - uses measured area first and replaces it with reported area if not measured +gen field_size = area_meas_hectares +replace field_size = reported_area if local_unit==1 & gps_meas==0 //reported in hectares - 14 changes +replace field_size = reported_area/10000 if local_unit==2 & gps_meas==0 //reported in sq meters - 17 changes +replace field_size = reported_area*conversion/10000 if !inlist(local_unit,1,2) & field_size == . & conversion != . // 19 changes + +*Using our own created conversion factors for still missings observations merge m:1 region zone local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", nogen -replace area_meas_hectares = (area*(sqmeters_per_unit_zone/10000)) if local_unit!=11 & area_meas_hectares==. & obs_zone>=10 +replace field_size = (reported_area*(sqmeters_per_unit_zone/10000)) if local_unit!=11 & field_size==. & obs_zone>=10 merge m:1 region local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", nogen -replace area_meas_hectares = (area*(sqmeters_per_unit_region/10000)) if local_unit!=11 & area_meas_hectares==. & obs_region>=10 +replace field_size = (reported_area*(sqmeters_per_unit_region/10000)) if local_unit!=11 & field_size==. & obs_region>=10 merge m:1 local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", nogen -replace area_meas_hectares = (area*(sqmeters_per_unit_country/10000)) if local_unit!=11 & area_meas_hectares==. -count if area!=. & area_meas_hectares==. -replace area_meas_hectares = 0 if area_meas_hectares == . -lab var area_meas_hectares "Field area measured in hectares, with missing obs imputed using local median per-unit values" -merge 1:1 holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_gender_dm.dta", nogen +replace field_size = (reported_area*(sqmeters_per_unit_country/10000)) if local_unit!=11 & field_size==. +count if reported_area!=. & field_size==. +replace field_size = 0 if field_size == . // 4 real changes +lab var area_meas_hectares "Field area measured in hectares with GPS" +lab var field_size "Field area measured in hectares, with missing replaced with farmer reported area, some imputed using local median per-unit values" + +merge 1:1 holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers.dta", nogen gen area_meas_hectares_male = area_meas_hectares if dm_gender==1 gen area_meas_hectares_female = area_meas_hectares if dm_gender==2 gen area_meas_hectares_mixed = area_meas_hectares if dm_gender==3 -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", replace -*/ +keep saq* hhid holder_id parcel_id field_id cultivated s3q03 area_meas_hectares* field_size gps_meas s3q13 s3q15_* +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", replace *Parcel Area -collapse (sum) land_size = area_meas_hectares area_meas_hectares, by(household_id holder_id parcel_id) -lab var land_size "Parcel area measured in hectares, with missing obs imputed using local median per-unit values" +collapse (sum) land_size = field_size, by(hhid holder_id parcel_id) +lab var land_size "Parcel area measured in hectares with GPS, with missing replaced with farmer reported area" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcel_area.dta", replace *Household Area -collapse (sum) area_meas_hectares_hh = land_size, by(household_id) -lab var area_meas_hectares_hh "Total area measured in hectares, with missing obs imputed using local median per-unit values" +collapse (sum) field_size_hh = land_size, by(hhid) +lab var field_size_hh "Total area measured in hectares, with missing replaced with farmer reported area" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_household_area.dta", replace *Cultivated (HH) area use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear keep if cultivated==1 -collapse (sum) farm_area = area_meas_hectares, by (household_id) -lab var farm_area "Land size, all cultivated plots (denominator for land productivitiy), in hectares" +collapse (sum) farm_area = field_size, by (hhid) +lab var farm_area "Land size, all cultivated plots (denominator for land productivity), in hectares" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farm_area.dta", replace *Agricultural land summary and area use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear gen agland = (s3q03==1 | s3q03==2 | s3q03==3 | s3q03==5) // Cultivated, pasture, fallow, or prepared for Belg season. Excludes forest, home/homestead and "other" (which includes everything from "eucalyptus tree" to storage and land "used for belge") keep if agland==1 -keep household_id parcel_id field_id holder_id agland area_meas_hectares -ren area_meas_hectares farm_size_agland_field +keep hhid parcel_id field_id holder_id agland field_size +ren field_size farm_size_agland_field lab var farm_size_agland "Field size in hectares, including all plots cultivated, fallow, or pastureland" lab var agland "1= Plot was used for cultivated, pasture, or fallow" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_agland.dta", replace +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_agland.dta", replace *Agricultural land area household -collapse (sum) farm_size_agland = farm_size_agland_field, by (household_id) +collapse (sum) farm_size_agland = farm_size_agland_field, by (hhid) lab var farm_size_agland "Total land size in hectares, including all plots cultivated, fallow, or pastureland" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmsize_all_agland.dta", replace + +****Conversion Factors + +//ALT: New +*Before harvest, need to prepare the conversion factors +use "$Ethiopia_ESS_W4_temp_data/Crop_CF_Wave4.dta", clear +ren mean_cf_nat mean_cf100 +sort crop_code unit_cd mean_cf100 +duplicates drop crop_code unit_cd, force +*BET 07.16.2021 CHECK HERE: there are two regions that appear in PH files that do not appear in the conversion files (13. Harar, 15. Dire Dawa) but these use the same conversion factor as Somalie which is recoded to 5 +gen mean_cf13= mean_cf99 // +gen mean_cf15 = mean_cf99 +reshape long mean_cf, i(crop_code unit_cd) j(region) +recode region (99=5) +ren mean_cf conversion +ren unit_cd unit +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cf.dta", replace + + *************************** + *Crop Values + *************************** + + * Using SECTION 11 for prices that farmers actually received for specific crops at the household level +use "${Ethiopia_ESS_W4_temp_data}/sect11_ph_w4.dta", clear + ren household_id hhid + ren saq01 region + ren saq02 zone + ren saq03 woreda + ren saq04 kebele + ren saq05 ea + ren saq14 rural + + * Note that variable names are inconsistent in number and name between ESS Waves + ren s11q01 crop_code + keep if s11q07==1 // Did you sell any crop? Interested in the value of quantity sold. + ren s11q03a1 qty_harv + ren s11q03a2 unit_harv + ren s11q11a qty //qty sold + ren s11q11b unit //unit sold + drop if unit == . // 6 obs dropped + // ren s11q11b_os unit_os // MGM 4.1.2024: 69 o/s obs - can backfill later + ren s11q12 val_sold // actual value received for qty/unit of crop + // ren s11q27a percent_sold // MGM 4.25.24: this is not percent_sold - this is percent of stored crop intended for sales + drop if val_sold==0 | val_sold==. // 23 observations dropped + + keep hhid region zone woreda kebele ea rural crop_code qty unit val_sold qty_harv unit_harv + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keepusing(weight) keep(1 3) // MGM 4.1.2024: all 2,743 observations matched + + collapse (sum) val_sold qty qty_harv, by(hhid region zone woreda kebele ea crop_code unit weight) + gen price_unit = val_sold/qty // H1 - see hierarchy above + gen obs=price_unit!=. + + *H2 - see hierarchy above + foreach i in region zone woreda kebele ea hhid { + preserve + bys `i' crop_code unit : egen obs_`i'_price = sum(obs) + collapse (median) price_unit_`i'=price_unit [aw=weight], by (`i' unit crop_code obs_`i'_price) + tempfile price_unit_`i'_median + save `price_unit_`i'_median' + restore + } + preserve + collapse (median) price_unit_country = price_unit (sum) obs_country_price=obs [aw=weight], by(crop_code unit) + tempfile price_unit_country_median + save `price_unit_country_median' + restore + + merge m:1 region crop_code unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cf.dta", keep (1 3) + * 566 observations not matched from master + * 162 are kilogram and 67 are o/s - no need to worry about these + * ~ 400 observations of non-standard units on crops that we do not have conversion factors for - we will want to go back and try to make more matches if possible! + replace conversion=1 if unit==1 // kgs + replace conversion=100 if unit==3 & _merge==1 // MGM 4.18.2024: double check with ALT if we can do this... 1 quintal = 100 kgs + + gen qty_kg = qty*conversion //405 missing values generated (see above for what these are) + gen price_kg = val_sold/qty_kg // H5 - see hierarchy above + drop if price_kg == . //405 observations deleted + replace obs=1 // 0 real changes + + * H6 - see hierarchy above + foreach i in region zone woreda kebele ea hhid { + preserve + bys `i' crop_code : egen obs_`i'_pkg = sum(obs) + collapse (median) price_kg_`i'=price_kg [aw=weight], by (`i' crop_code obs_`i'_pkg) + tempfile price_kg_`i'_median + save `price_kg_`i'_median' + restore + } + preserve + bys crop_code : egen obs_country_pkg = sum(obs) + collapse (median) price_kg_country = price_kg [aw=weight], by(crop_code obs_country_pkg) + tempfile price_kg_country_median + save `price_kg_country_median' + restore + + collapse (sum) qty_harv qty val_sold, by(hhid crop_code unit) + ren qty qty_sold + la var qty_harv "Quantity Harvested" + la var qty_sold "Quantity Sold" + la var val_sold "Value of Quantity Sold" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_harv_vals_hhids.dta" , replace + + *************************** + *Plot Variables + *************************** +use "${Ethiopia_ESS_W4_temp_data}/sect9_ph_w4", clear //renaming variables to make merge work (below) + ren household_id hhid + ren saq01 region + ren saq02 zone + ren saq03 woreda + ren saq04 kebele + ren saq05 ea + ren s9q01 crop_name + ren s9q00b crop_code + gen season_ph=1 +tempfile sect9_ph_w4 +save `sect9_ph_w4' + +use "${Ethiopia_ESS_W4_temp_data}/sect4_pp_w4.dta", clear + ren household_id hhid + ren saq01 region + ren saq02 zone + ren saq03 woreda + ren saq04 kebele + ren saq05 ea + ren s4q01a crop_name1 + ren s4q01b crop_code1 //crop_code1 for now - checking for problems with upcoming merge + gen season_pp=1 + + merge 1:1 hhid holder_id parcel_id field_id crop_id using `sect9_ph_w4', nogen + *_m==1 indicates that data were reported in pp but not ph + *_m==2 indicates that data were reported in ph but not pp + * Need to fix these later! + + + //Reconciling a few cases where crop_codes are not consistent across pp and ph data + gen mismatch = crop_code!=crop_code1 + replace crop_code=crop_code1 if crop_code==. & mismatch==1 //630 changes + replace crop_code1=crop_code if crop_code1==. & mismatch==1 //163 changes + gen crop_code_r=. //crop_code fix + replace crop_code_r = min(crop_code1, crop_code) if (crop_code1 > 97 | crop_code > 97) & mismatch==1 //52 occurences where "OTHER CROP" was listed in either ph or pp but not the other + replace crop_code=crop_code_r if crop_code>97 & crop_code_r!=. //8 changes + replace crop_code1=crop_code_r if crop_code1>97 & crop_code_r!=. //19 changes + *Kariya is a jalapeno + replace crop_code1=59 if strpos(crop_name1, "ariya") & mismatch==1 //4 changes + replace crop_code=59 if strpos(crop_name, "ariya") & mismatch==1 //0 changes + *Buna is coffee + replace crop_code1=72 if strmatch(crop_name1, "buna") & mismatch==1 //3 changes + replace crop_code=72 if strmatch(crop_name, "buna") & mismatch==1 //0 changes + *Muz is banana + replace crop_code1=42 if strmatch(crop_name1, "muz") & mismatch==1 //1 change + replace crop_code=42 if strmatch(crop_name, "muz") & mismatch==1 //0 change + replace mismatch=0 if crop_code==crop_code1 //826 real changes + drop if mismatch==1 //58 observations deleted - WB needs to fix cases where crop_name and crop_code are mislabeled or crop_ids swap between pp and ph (MAIZE CHAT) (HORSEBEANS PUMPKINS) (RED PEPPER GREEN PEPPER) (PAPAYA MANGO) + drop crop_code1 + + + + *Fix crop_code labels + la def cropcode 1 "barley" 2 "maize" 3 "millet" 4 "oats" 5 "rice" 6 "sorghum" 7 "teff" 8 "wheat" 9 "mung bean" 10 "cassava" 11 "chick peas" 12 "haricot beans" 13 "horse beans" /*=fava bean*/ 14 "lentils" 15 "field peas" 16 "vetch" /*ALT: not a food crop*/ 17 "gibto" /*ALT: White lupin*/ 18 "soybeans" 19 "kidney beans" 20 "fennel" 21 "castor beans" 22 "cottonseed" 23 "flaxseed" 24 "groundnuts" 25 "nueg" /*Nyjerseed, feed crop*/ 26 "rapeseed" /*i.e. canola*/ 27 "sesame" 28 "sunflower" 29 "mego" 30 "savory" 31 "black cumin" /*Nigella*/ 32 "black pepper" 33 "cardamom" 34 "chili pepper" 35 "cinnamon" 36 "fenugreek" 37 "ginger" 38 "red pepper" 39 "tumeric" 40 "white lupin" /*ALT: This is the same as 17, does the separate cropcode imply it's being used as livestock forage or cover? */ 41 "apples" 42 "bananas" 43 "grapes" 44 "lemons" 45 "mandarins" 46 "mangos" 47 "oranges" 48 "papaya" 49 "pineapple" 50 "citron" 51 "beer root" /*I cannot find any English-language references to this outside of LSMS - is it supposed to be beetroot? */ 52 "cabbage" 53 "carrot" 54 "cauliflower" 55 "garlic" 56 "kale" 57 "lettuce" 58 "onion" 59 "green pepper" 60 "potatoes" 61 "pumpkin" 62 "sweet potato" 63 "tomatoes" 64 "godere" /*ALT: Likely taro, should update crop codes to reduce regional variants like this one */ 65 "guava" 66 "peach" 67 "mustard" 68 "feto" /*garden cress?*/ 69 "spinach" 70 "green beans" 71 "chat" 72 "coffee" 73 "cotton" 74 "enset" 75 "gesho" /*buckthorn*/ 76 "sugarcane" 77 "tea" 78 "tobacco" 79 "coriander" 80 "sacred basil" /* tulsi */ 81 "rue" 82 "gishita" /*soursop*/ 83 "watermelon" 84 "avocado" 85 "forage" /*clarifying this from "Grazing land" */ 86 "temporary gr" /*Temporary forage? Not clear what this is*/ 97 "pijapin" /*Doesn't appear outside of LSMS, no obs */ 98 "other root crop" /*Cut off by char limit?*/ 99 "other land" 108 "amboshika" /*skipping 100-112, no obs, no idea what some of these are. Couldn't find any database entries with NL20F. */ 112 "kazmir" /*white sapote*/ 113 "strawberry" 114 "shiferaw" /*moringa*/ 115 "other fruit" 116 "timez kimem" /*Spice?*/ 117 "other spices" 118 "other pulses" 119 "other oilseed" 120 "other cereal" 121 "other case crop" /*=cover crop?*/ 123 "other vegetable" + la val crop_code cropcode + + drop if hhid=="2030406088800801079" | hhid=="030406088800801079" //not cultivated/agland but reports area planted/harvested + +* GENERATE PURESTAND, RELAY (FIELD-LEVEL) + ren s4q02 crop_stand + ren s9q02 crop_stand_ph + gen crop_code_master = crop_code + gen perm_tree = inlist(crop_code_master, 10, 35, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 65, 66, 72, 74, 75, 76, 82, 84, 112, 115) //MGM 4.11.2024: why are we classifying other spices as perm_tree? + lab var perm_tree "1 = Tree or permanent crop" + + gen month_planted = s4q13a + gen year_planted = s4q13b + //ALT: Some reports of planting in ETH calendar year 2011 after postplanting survey, which ended in month 2 + replace month_planted = . if year_planted==2011 & month_planted > 2 + + gen month_harv_min = s9q08a //rowmin(s9q08a s9q08b) + gen year_harv_begin = year_planted + (month_harv_min <= month_planted & year_planted == 2010) + replace month_harv_min = month_harv_min + 13 if year_harv_begin == 2011 //if month_harv_min<=month_planted + replace month_planted = month_planted + 13 if year_planted == 2011 //13 months in Ethiopia + ren month_harv_min month_harvest + gen months_grown = month_harvest - month_planted if perm_tree == 0 + la val month_planted s9q08a + la val month_harvest s9q08a + + + gen lost_drought = s9q14==1 + gen lost_flood = s9q14==2 | s9q14==7 + gen lost_crop=s9q15==100 + + //lazy way to discover number of crops on plot taking into account duplicate entries + preserve + keep hhid holder_id parcel_id field_id crop_code + duplicates drop + collapse (count) crops_plot=crop_code, by(hhid holder_id parcel_id field_id) + tempfile crops_plot + save `crops_plot' + restore + merge m:1 hhid holder_id parcel_id field_id using `crops_plot' + + gen purestand = crops_plot == 1 + //Only interested in temp crops here, so we have to hide the perm crop months. Missings are considered arbitrarily large, so they'll get caught in the max function. + replace month_planted = 0 if perm_tree == 1 + bys hhid holder_id parcel_id field_id : egen max_mo_planted = max(month_planted) + replace month_planted = . if perm_tree == 1 + bys hhid holder_id parcel_id field_id : egen min_mo_harvest = min(month_harvest) + gen relay = max_mo_planted > min_mo_harvest & purestand==0 + + lab var purestand "1 = monocropped, 0 = intercropped or relay cropped" //63% of plots purestand, 1% of plots relay + + + //ALT: Not sure what the function of this block is. + + preserve + collapse (mean) purestand relay, by(hhid holder_id parcel_id field_id crop_code) + keep hhid holder_id parcel_id field_id purestand relay crop_code + tempfile plot_vars + save `plot_vars' // variables at the plot level + restore + +* MONTHS_GROWN, HA_PLANTED, HA_HARVEST, AND NUMBER_TREES_PLANTED (PER CROP PER FIELD) +ren s4q03 perc_planted_pp +ren s9q03 perc_planted_ph +ren s9q11 perc_plant_harv // what percent of the planted area has been harvested? +* Backfilling some missing perc_planted data +replace perc_planted_pp=perc_planted_ph if perc_planted_pp==. & perc_planted_ph!=. // 82 real changes +replace perc_planted_ph=perc_planted_pp if perc_planted_ph==. & perc_planted_pp!=. // 253 real changes +* MGM 5.1.2024: Noting that roughly 20% of observations have discrepancies between percent planted reported in pp vs. ph. Whether or not a plot had damage was equally distributed across all categories (pppp). Also, there did not seem to be a relationship between % damage and difference in reported perc_planted across pp and ph data. This indicates that there is no particular bias... so we are choosing to use pp on the premise that it may be more reliable than ph. + preserve + ren s9q10 less_than_plant // was area planted less than area harvested? + rename s4q16 number_trees_planted //this var name feels like a misnomer because they exist but were not necessarily planted that year + replace crop_stand=2 if crops_plot>1 //multiple crops were grown on these plots + merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", nogen keep(1 3) keepusing(field_size) // 25 not matched from master + gen ha_planted = field_size * perc_planted_pp / 100 + replace ha_planted = field_size if crop_stand == 1 & ha_planted == . //0 changes + gen ha_harvest = ha_planted if less_than_plant == 2 // was area planted less than area harvested? 2=no + replace ha_harvest = field_size * (perc_planted_pp/100) * (perc_plant_harv/100) if ha_harvest==. + replace ha_harvest = 0 if ha_harvest == . + replace ha_harvest=ha_planted if ha_harvest>ha_planted //0 changes + + * Rescaling percent_field as some plots report more hectares planted than measured + gen percent_field = ha_planted/field_size + bys hhid holder_id parcel_id field_id : egen total_percent = total(percent_field) + replace percent_field = percent_field/total_percent if total_percent > 1 & purestand == 0 & relay==0 // 192 changes + replace percent_field = 1 if percent_field > 1 & purestand == 1 | relay==1 // 63 changes + + collapse (sum) ha_planted ha_harvest number_trees_planted percent_field (mean) months_grown, by(hhid holder_id parcel_id field_id crop_code) // adding crops_stand + tempfile planting_area + save `planting_area' // contains ha_planted, ha_harvest & number_trees_planted by crop by field + restore + +* GENERATE QUANT_HARV_KG, VALUE_HARVEST (PER CROP PER FIELD) + * CROP PRICES / VALUES + ren s9q05a qty_harv + ren s9q05b unit //2,767 obs have missing unit information + ren s9q06 kg_est + replace qty_harv=kg_est if (qty_harv==. | unit==.) & kg_est!=. // 5 changes + replace unit=1 if (qty_harv==. | unit==.) & kg_est!=. // 4 changes + // keep region zone woreda kebele ea hhid holder_id parcel_id field_id crop_code s4q21a qty_harv unit kg_est + + merge m:1 crop_code unit region using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cf.dta", nogen keep(1 3) + + * Merge in price per unit and price per kg - generated from S11 + foreach i in region zone woreda kebele ea hhid { + merge m:1 `i' crop_code unit using `price_unit_`i'_median', nogen keep(1 3) + merge m:1 `i' crop_code using `price_kg_`i'_median', nogen keep(1 3) + } + merge m:1 unit crop_code using `price_unit_country_median', nogen keep(1 3) + merge m:1 crop_code using `price_kg_country_median', nogen keep(1 3) + + gen price_unit = . + gen price_kg = . + + foreach i in country region zone woreda kebele ea { + replace price_unit = price_unit_`i' if obs_`i'_price>9 & obs_`i'_price != . + replace price_kg = price_kg_`i' if obs_`i'_pkg>9 & obs_`i'_price != . + + } + + * Household price/unit is preferred + replace price_unit = price_unit_hhid if price_unit_hhid != . //comment out this line if you would prefer to use the area medians for all observations + replace price_kg = price_kg_hhid if price_kg_hhid != . //comment out this line if you would prefer to use the area medians for all observations + +/* + * Dropping geo median variables + foreach i in country region zone woreda kebele ea hhid { + drop obs_`i'_price + drop obs_`i'_pkg + drop price_unit_`i' + drop price_kg_`i' + } +*/ + * VALUE HARVEST + gen value_harvest = qty_harv*price_unit if unit>1 + replace value_harvest = qty*price_kg if unit == 1 + + * QTY KGS + gen quant_harv_kg = qty_harv if unit == 1 + replace quant_harv_kg = qty_harv * conversion if unit > 1 + + * BACKFILLING MORE VALUE HARVEST + * For still missing value_harvest, convert to kg and multiply price_kg + replace qty_harv = qty_harv*conversion if value_harvest == . & conversion != . // for missing vals, convert to kg and multiply by price_kg + replace unit = 1 if value_harvest == . & conversion != . // adjusting units for the above line of code + replace value_harvest = qty_harv*price_kg if value_harvest == . //2,162 changes + + * For still missing value_harvest, use country prices even if we do not have enough obs for a reliable median - MGM 4.29.2024: is this reasonable? + replace value_harvest = qty_harv*price_kg_country if unit == 1 & value_harvest == . // 1,114 changes + replace value_harvest = qty_harv*price_unit_country if unit>1 & value_harvest == . // 119 changes + + collapse (sum) value_harvest quant_harv_kg, by(region zone woreda kebele ea hhid holder_id parcel_id field_id crop_code) + merge m:1 hhid holder_id parcel_id field_id crop_code using `planting_area', nogen // all matched + merge m:1 hhid holder_id parcel_id field_id crop_code using `plot_vars', nogen // all matched + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) // 75 not matched from master + gen fieldweight = ha_planted * weight + gen yield = quant_harv_kg / ha_planted // MGM 4.17.2024: Need to check if yield values are reasonable + + ren crop_code crop_code_master // MGM 4.29.2024: other waves have just generated a var from the original - need to revisit if we should have a long and short version for ETH? + sort hhid holder_id parcel_id field_id crop_code_master + quietly by hhid holder_id parcel_id field_id crop_code_master: gen dup = cond(_N==1,0,_n) + tab dup + drop if dup > 1 //81 observations dropped //ALT 12.27: updated from 0 to 1 - we should keep the original. We should check if this is an issue with the raw dta files or if there's a weird merge result here. // Joaquin 03.16: No dups + drop if quant_harv_kg ==. + + + merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", nogen keep(1 3) keepusing(field_size cultivated gps_meas) // 25 not matched + keep region zone woreda kebele ea hhid holder_id parcel_id field_id purestand relay /*crops_plot*/ crop_code_master val* quant* cultivated ha_planted number_trees_planted percent_field months_grown /*reason_loss*/ field_size gps_meas + + + *report duplicates + sort hhid holder_id parcel_id field_id crop_code_master + quietly by hhid holder_id parcel_id field_id crop_code_master: gen dup = cond(_N==1,0,_n) + tab dup + drop if dup > 1 // 0 obs deleted + drop dup + drop if hhid =="" // 0 obs deleted + + *AgQuery + collapse (sum) quant_harv_kg value_harvest ha_planted percent_field number_trees_planted (max) months_grown cultivate /*(first) crops_plot reason_loss*/, by(region zone woreda kebele ea hhid holder_id parcel_id field_id crop_code_master purestand relay field_size gps_meas) + bys hhid holder_id parcel_id field_id : egen percent_area = sum(percent_field) + bys hhid holder_id parcel_id field_id : gen percent_inputs = percent_field / percent_area + drop percent_area //Assumes that inputs are +/- distributed by the area planted. Probably not true for mixed tree/field crops, but reasonable for plots that are all field crops + + bysort hhid holder_id parcel_id field_id: gen dup=cond(_N==1,0,_n) + tab dup + drop dup + gen ha_harvest = ha_planted + drop if parcel_id == "" + //ALT QUICK FIX + ren hhid household_id + merge m:1 household_id holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers.dta", nogen keep(1 3) keepusing(dm_gender) // 11 not matched + ren household_id hhid + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + tab dup + drop dup + +order region zone woreda kebele ea hhid holder_id parcel_id field_id crop_code_master +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", replace + + + +//ALT: old + +/* ******************************************************************************** *MONOCROPPED CROPS* ******************************************************************************** global nb_topcrops : word count $topcrop_area -use "${Ethiopia_ESS_W4_raw_data}/Post-Planting/sect4_pp_W4.dta", clear +use "${Ethiopia_ESS_W4_temp_data}/sect4_pp_W4.dta", clear ren s4q01b crop_code *recoding common beans to a single category recode crop_code (19=12) @@ -523,12 +1148,14 @@ forvalues k=1(1)$nb_topcrops { save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_`cn'_monocrop_hh_area.dta", replace restore } +*/ +//ALT: TO UPDATE ******************************************************************************** *GROSS CROP REVENUE ******************************************************************************** *Crops including tree crops, vegetables, root crops -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect11_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_ph_W4.dta", clear ren saq01 region ren saq02 zone ren saq03 woreda @@ -549,7 +1176,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales_1.dta", replace /* KEF: Old code. There is no section 12 in W4. It seems like there is no distinguishing between tree crops/veggie/root crops like there was in the previous waves. ren saq01 region *Tree crops, vegetables, root crops -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect12_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect12_ph_W4.dta", clear ren saq02 zone ren saq03 woreda ren saq06 kebele @@ -568,7 +1195,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales_2.dta", replace use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales_1.dta", clear //append using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales_2.dta" KEF: unnecessary from old code -merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", nogen keep(1 3) // KEF: Created a dummy as a unique identifier, thus used this in place of the original conversion factors. 378 not matched, maybe because not all of the conversion factors existed. +merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4.dta", nogen keep(1 3) // KEF: Created a dummy as a unique identifier, thus used this in place of the original conversion factors. 378 not matched, maybe because not all of the conversion factors existed. gen kgs_sold = quantity_sold * mean_cf_nat /* Here, if conversion value is missing, this will be a missing observation in the imputed median price estimation. */ collapse (sum) kgs_sold value_sold (max) percent_sold, by (household_id crop_code) /* For duplicated obs, we'll take the maximum reported % sold. */ @@ -577,14 +1204,15 @@ lab var price_kg "Price received per kgs sold" drop if price_kg==. | price_kg==0 keep household_id crop_code price_kg value_sold percent_sold kgs_sold merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) +replace hhid = household_id if hhid=="" //ALT FOLLOW UP *replace crop_code=6 if household_id=="030101088800204020" & crop_code==1 /* Typo, crops mismatched between files on production and sales */ //KEF How do I know if there is a crop mismatch here? -destring region zone woreda, replace +//destring region zone woreda, replace save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", replace use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys region zone woreda kebele ea crop_code: egen obs_ea = count(observation) -collapse (median) price_kg [aw=weight], by (region zone woreda kebele ea crop_code obs_ea) +collapse (median) price_kg [aw=weight_pop_rururb], by (region zone woreda kebele ea crop_code obs_ea) ren price_kg price_kg_median_ea lab var price_kg_median_ea "Median price per kg for this crop in the enumeration area" lab var obs_ea "Number of sales observations for this crop in the enumeration area" @@ -592,7 +1220,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_ea.dta", repla use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys region zone woreda kebele crop_code: egen obs_kebele = count(observation) -collapse (median) price_kg [aw=weight], by (region zone woreda kebele crop_code obs_kebele) +collapse (median) price_kg [aw=weight_pop_rururb], by (region zone woreda kebele crop_code obs_kebele) ren price_kg price_kg_median_kebele lab var price_kg_median_kebele "Median price per kg for this crop in the kebele" lab var obs_kebele "Number of sales observations for this crop in the kebele" @@ -600,7 +1228,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_kebele.dta", r use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys region zone woreda crop_code: egen obs_woreda = count(observation) -collapse (median) price_kg [aw=weight], by (region zone woreda crop_code obs_woreda) +collapse (median) price_kg [aw=weight_pop_rururb], by (region zone woreda crop_code obs_woreda) ren price_kg price_kg_median_woreda lab var price_kg_median_woreda "Median price per kg for this crop in the woreda" lab var obs_woreda "Number of sales observations for this crop in the woreda" @@ -608,7 +1236,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_woreda.dta", r use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys region zone crop_code: egen obs_zone = count(observation) -collapse (median) price_kg [aw=weight], by (region zone crop_code obs_zone) +collapse (median) price_kg [aw=weight_pop_rururb], by (region zone crop_code obs_zone) ren price_kg price_kg_median_zone lab var price_kg_median_zone "Median price per kg for this crop in the zone" lab var obs_zone "Number of sales observations for this crop in the zone" @@ -616,7 +1244,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_zone.dta", rep use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys region crop_code: egen obs_region = count(observation) -collapse (median) price_kg [aw=weight], by (region crop_code obs_region) +collapse (median) price_kg [aw=weight_pop_rururb], by (region crop_code obs_region) ren price_kg price_kg_median_region lab var price_kg_median_region "Median price per kg for this crop in the region" lab var obs_region "Number of sales observations for this crop in the region" @@ -624,13 +1252,13 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_region.dta", r use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", clear gen observation = 1 bys crop_code: egen obs_country = count(observation) -collapse (median) price_kg [aw=weight], by (crop_code obs_country) +collapse (median) price_kg [aw=weight_pop_rururb], by (crop_code obs_country) ren price_kg price_kg_median_country lab var price_kg_median_country "Median price per kg for this crop in the country" lab var obs_country "Number of sales observations for this crop in the country" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_country.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear ren s9q06 kgs_harvest *************** @@ -638,7 +1266,7 @@ ren s9q06 kgs_harvest ta kgs_harvest // some of the values of ESTIMATED kgs harvest are extremely larger. We will use values reported in conventional unit as much as possible and complement with estimates only when missings. gen unit_cd= s9q05b ren s9q00b crop_code -merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", nogen keep(1 3) // KEF: +merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4.dta", nogen keep(1 3) // KEF: ren s9q05a harvest_reported ren s9q05b harvest_reported_unit replace kgs_harvest = harvest_reported * mean_cf_nat @@ -681,9 +1309,10 @@ lab var value_crop_production "Gross value of crop production, summed over main gen value_crop_sales = value_sold lab var value_crop_sales "Value of crops sold so far, summed over main and short season" lab var kgs_harvest "Kgs harvested of this crop, summed over main and short season" - +//ALT QUICK FIX +ren household_id hhid save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production.dta", replace -collapse (sum) value_harvest value_sold, by (household_id) +collapse (sum) value_harvest value_sold, by (hhid) ren value_harvest value_crop_production lab var value_crop_production "Gross value of crop production for this household" *This is estimated using local median values of observed sales in which the sales unit is also found in the conversion table. @@ -693,11 +1322,11 @@ ren value_sold value_crop_sales lab var value_crop_sales "Value of crops sold so far" gen proportion_cropvalue_sold = value_crop_sales / value_crop_production lab var proportion_cropvalue_sold "Proportion of crop value produced that has been sold" -drop if household_id=="" +drop if hhid=="" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_production.dta", replace *Value crop production by parcel -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear ren s9q06 kgs_harvest @@ -706,7 +1335,7 @@ ren s9q06 kgs_harvest ta kgs_harvest // some of the values of ESTIMATED kgs harvest are extremely larger. We will use values reported in conventional unit as much as possible and complement with estimates only when missings. gen unit_cd= s9q05b ren s9q00b crop_code -merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", nogen keep(1 3) // KEF: +merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4.dta", nogen keep(1 3) // KEF: ren s9q05a harvest_reported ren s9q05b harvest_reported_unit replace kgs_harvest = harvest_reported * mean_cf_nat @@ -763,28 +1392,30 @@ lab var value_crop_production "Gross value of crop production" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_production_household.dta", replace *Crop losses and value of consumption -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect11_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_ph_W4.dta", clear ren s11q21a1 quantity_lost ren s11q21a2 quantity_lost_units /* We can't value this for now KEF: why not? There are also 14 responses using other units. */ ren s11q21a3 percent_lost ren s11q01 crop_code /*KEF: There is no section 12 in the W4 questionnaire. -append using "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect12_ph_W4.dta" +append using "$Ethiopia_ESS_W4_temp_data/sect12_ph_W4.dta" ren ph_s12q12 share_lost ren ph_s12q13 value_lost /* It's not clear why different types of crops were valued so differently. */ replace percent_lost = share_lost if percent_lost==.*/ -merge m:1 household_id crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production.dta" //KEF: 1,148 not matched. +//ALT QUICK FIX +ren household_id hhid +merge m:1 hhid crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production.dta" //KEF: 1,148 not matched. drop if _merge==2 drop _merge *It is evident that sometimes crops were harvested but then the module on sales was not asked. *498 cases where the amount lost was reported in quantity (crop-units) but no percent lost is given. *Use conversion file to get from units to kgs, then use the price files to get from kgs to monetary values. ren quantity_lost_units unit_cd -merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", nogen keep(1 3) //KEF: used the dummy version of the conversion factors again (see beginning of this section) since these did not uniquely identify observations in the raw conversion factors. +merge m:1 crop_code unit_cd using "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4.dta", nogen keep(1 3) //KEF: used the dummy version of the conversion factors again (see beginning of this section) since these did not uniquely identify observations in the raw conversion factors. gen kgs_lost = quantity_lost * mean_cf_nat sum kgs_lost if percent_lost==0 /* If both a quantity and share lost were given, we'll take the share to be consistent with section 12. */ lab var kgs_lost "Estimated number of kgs of this crop that were lost post-harvest" -merge m:1 household_id crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", nogen //KEF: 7,111 not matched +merge m:1 hhid crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_sales.dta", nogen //KEF: 7,111 not matched merge m:1 region zone woreda kebele crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_kebele.dta", nogen merge m:1 region zone woreda crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_woreda.dta", nogen merge m:1 region zone crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_prices_zone.dta", nogen @@ -810,16 +1441,18 @@ recode crop_value_lost (.=0) *Also including transport costs for crop sales here ren s11q17 value_transport_cropsales recode value_transport_cropsales (.=0) -collapse (sum) crop_value_lost value_transport_cropsales, by (household_id) +collapse (sum) crop_value_lost value_transport_cropsales, by (hhid) lab var crop_value_lost "Value of crop losses" lab var value_transport_cropsales "Expenditures on transportation for crop sales of temporary crops" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_losses.dta", replace +//ALT: Old +/* ******************************************************************************** *CROP EXPENSES ******************************************************************************** *Expenses: Hired labor -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear ren s3q30a number_men ren s3q30b number_days_men ren s3q30c wage_perday_men @@ -847,7 +1480,7 @@ collapse (sum) wages_paid_aglabor_postplant, by (household_id) lab var wages_paid_aglabor_postplant "Wages paid for hired labor (crops), as captured in post-planting survey" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wages_postplanting.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect10_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect10_ph_W4.dta", clear ren s10q01a number_men ren s10q01b number_days_men ren s10q01c wage_perday_men @@ -878,7 +1511,7 @@ lab var wages_paid_aglabor_postharvest "Wages paid for hired labor (crops), as c save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wages_postharvest.dta", replace *Expenses: Inputs -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear ren s3q21d value_urea ren s3q22d value_DAP ren s3q23d value_NPS @@ -920,7 +1553,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fertilizer_costs.dta", rep *Other chemicals, manure (Values not captured for Ethiopia ESS) *Seeds -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect5_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect5_pp_W4.dta", clear ren s5q06 cost_transport_purchased_seed ren s5q07 value_purchased_seed ren s5q15 cost_transport_free_seed @@ -933,7 +1566,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_seed_costs.dta", replace *Value of seed purchased (not just improved seed) is also captured here. *Land rental -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", clear gen rented_plot = (s2q05==3) ren s2q10a rental_cost_cash ren s2q10b rental_cost_inkind @@ -976,41 +1609,819 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_rental_costs.dta", re *Rental of agricultural tools, machines = Not captured. *Transport costs for crop sales -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect11_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_ph_W4.dta", clear ren s11q17 transport_costs_cropsales recode transport_costs_cropsales (.=0) collapse (sum) transport_costs_cropsales, by (household_id) lab var transport_costs_cropsales "Expenditures on transportation for crop sales of temporary crops" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_transportation_cropsales.dta", replace +*/ ******************************************************************************** -*LIVESTOCK INCOME +* CROP EXPENSES ******************************************************************************** -*BET 05.26.2021 -*Expenses -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear -append using "$Ethiopia_ESS_W4_raw_data/sect8_3_ls_w4.dta" -append using "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_w4.dta" -ren ls_s8_3q11 cost_water_livestock -ren ls_s8_3q14 cost_fodder_livestock -ren ls_s8_3q22 cost_vaccines_livestock -ren ls_s8_3q24 cost_treatment_livestock -ren ls_s8_3q04 cost_breeding_livestock -recode cost_water_livestock cost_fodder_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock (.=0) -*Dairy costs + ********************************* + * LABOR * + ********************************* + // Joaquin 03.14.2023: Adapting to Nigeria. This is useful for merges below. Goal is to generate hh_cost_labor.dta + +use "${Ethiopia_ESS_W4_temp_data}/sect3_pp_w4.dta", clear // hired labor post planting + ren s3q30a numberhiredmale + ren s3q30d numberhiredfemale + ren s3q30g numberhiredchild + ren s3q30b dayshiredmale + ren s3q30e dayshiredfemale + ren s3q30h dayshiredchild + ren s3q30c wagehiredmale + ren s3q30f wagehiredfemale + ren s3q30i wagehiredchild + ren s3q31a numbernonhiredmale + ren s3q31c numbernonhiredfemale + ren s3q31e numbernonhiredchild + ren s3q31b daysnonhiredmale + ren s3q31d daysnonhiredfemale + ren s3q31f daysnonhiredchild + ren saq01 region + ren saq02 zone + ren saq03 woreda + ren saq06 kebele + ren saq07 ea + ren household_id hhid // Changed household_id to hhid + keep hhid holder_id parcel_id field_id *hired* + gen season="pp" +tempfile postplanting_hired +save `postplanting_hired' + +use "${Ethiopia_ESS_W4_temp_data}/sect10_ph_w4.dta" , clear // hired labor post harvest + ren s10q01a numberhiredmale + ren s10q01b dayshiredmale + ren s10q01c wagehiredmale //Wage per person/per day + ren s10q01d numberhiredfemale + ren s10q01e dayshiredfemale + ren s10q01f wagehiredfemale + ren s10q01g numberhiredchild + ren s10q01h dayshiredchild + ren s10q01i wagehiredchild + ren s10q03a numbernonhiredmale + ren s10q03b daysnonhiredmale + ren s10q03c numbernonhiredfemale + ren s10q03d daysnonhiredfemale + ren s10q03e numbernonhiredchild + ren s10q03f daysnonhiredchild + ren saq01 region + ren saq02 zone + ren saq03 woreda + ren saq06 kebele + ren saq07 ea + ren household_id hhid + keep region zone woreda kebele ea hhid holder_id parcel_id field_id *hired* //Changed household_id to hhid. Nigeria W3 do file keeps crop_code because of in-kin payments. No in-kind payments here. + collapse (sum) *hired*, by(region zone woreda kebele ea hhid holder_id parcel_id field_id) + gen season="ph" + tempfile postharvesting_hired + preserve + sort region zone woreda kebele ea hhid holder_id parcel_id field_id season + quietly by region zone woreda kebele ea hhid holder_id parcel_id field_id season: gen dup = cond(_N==1,0,_n) + tab dup + restore +save `postharvesting_hired' + +append using `postplanting_hired' // at field level + +unab vars : *female +local stubs : subinstr local vars "female" "", all +display "`stubs'" + +reshape long `stubs', i(region zone woreda kebele ea hhid holder_id parcel_id field_id season) j(gender) string + sort region zone woreda kebele ea hhid holder_id parcel_id field_id season +reshape long number days wage, i(hhid holder_id parcel_id field_id gender season) j(labor_type) string + gen val = days*number*wage + +merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) keepusing(weight) +merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", nogen keep(1 3) keepusing(area_meas_hectares) +gen fieldweight = weight*area_meas_hectares +recode wage (0=.) +gen obs=wage!=. + +*Median wages +foreach i in region zone woreda kebele ea hhid { preserve -keep if ls_type == 1 -collapse (sum) cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock, by (household_id) -egen cost_lrum = rowtotal (cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock) -keep household_id cost_lrum -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_lrum_expenses", replace -restore + bys `i' season gender : egen obs_`i' = sum(obs) + collapse (median) wage_`i'=wage [aw=fieldweight], by (`i' season gender obs_`i') + tempfile wage_`i'_median + save `wage_`i'_median' +restore +} +preserve +collapse (median) wage_country = wage (sum) obs_country=obs [aw=fieldweight], by(season gender) +tempfile wage_country_median +save `wage_country_median' +restore +drop obs fieldweight wage +tempfile all_hired +save `all_hired' + +// Family labor +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_w4.dta", clear + ren s3q29a pid1 + ren s3q29e pid2 + ren s3q29i pid3 + ren s3q29m pid4 + ren s3q29b weeks_worked1 + ren s3q29f weeks_worked2 + ren s3q29j weeks_worked3 + ren s3q29n weeks_worked4 + ren s3q29c days_week1 + ren s3q29g days_week2 + ren s3q29k days_week3 + ren s3q29o days_week4 + ren household_id hhid //Changed household_id to hhid +keep hhid holder_id parcel_id field_id pid* weeks_worked* days_week* preserve -ren ls_type livestock_code -gen species = (inlist(livestock_code,1)) + 2*(inlist(livestock_code,2)) + 3*(livestock_code==3) + 4*(livestock_code==5) + 5*(inlist(livestock_code,4)) + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + tab dup +restore +gen season="pp" +tempfile postplanting_family +save `postplanting_family' + +use "${Ethiopia_ESS_W4_temp_data}/Sect10_ph_w4.dta" , clear // Joaquin 04.03.23: Data is at crop level. Collapse at field level? + ren s10q02a pid1 + ren s10q02b weeks_worked1 + ren s10q02c days_week1 + ren s10q02e pid2 + ren s10q02f weeks_worked2 + ren s10q02g days_week2 + ren s10q02i pid3 + ren s10q02j weeks_worked3 + ren s10q02k days_week3 + ren s10q02m pid4 + ren s10q02n weeks_worked4 + ren s10q02o days_week4 + ren household_id hhid //Changed household_id to hhid + + keep hhid holder_id parcel_id field_id pid* weeks_worked* days_week* +preserve + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + tab dup +restore +collapse pid* weeks_worked* days_week*, by(hhid holder_id parcel_id field_id) +gen season="ph" +tempfile postharvesting_family +save `postharvesting_family' + +// Other labor +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_w4.dta", clear // Joaquin 03.24.23: Data is at field level + ren s3q31a numberothermale + ren s3q31b daysothermale + ren s3q31c numberotherfemale + ren s3q31d daysotherfemale + ren s3q31e numberotherchild + ren s3q31f daysotherchild + ren household_id hhid //Changed household_id to hhid +keep hhid holder_id parcel_id field_id number* days* +gen season = "pp" +tempfile postplanting_other +preserve + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + tab dup +restore +save `postplanting_other' + +use "${Ethiopia_ESS_W4_temp_data}/sect10_ph_w4.dta" , clear // Joaquin 03.24.23: Data is at crop level. Collapse at field level? + ren s10q03a numberothermale + ren s10q03b daysothermale + ren s10q03c numberotherfemale + ren s10q03d daysotherfemale + ren s10q03e numberotherchild + ren s10q03f daysotherchild + ren household_id hhid //Changed household_id to hhid +keep hhid holder_id parcel_id field_id number* days* +collapse number* days*, by(hhid holder_id parcel_id field_id) +preserve + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + tab dup +restore +gen season = "ph" +tempfile postharvesting_other +save `postharvesting_other' + +// Members +use "$Ethiopia_ESS_W4_temp_data/sect1_pp_w4.dta", clear + ren household_id hhid //Changed household_id to hhid + ren s1q00 pid + drop if pid==. + preserve + bysort hhid pid: gen dup=cond(_N==1,0,_n) + tab dup + bysort hhid pid: egen obs_num = sum(1) + tab obs_num + tab obs_num dup // Joaquin 04.03.24: Every duplicate is associated with only one person. + restore + ren s1q02 age + gen male = s1q03==1 + rename saq01 region + rename saq02 zone + rename saq03 woreda + rename saq06 kebele + rename saq07 ea + keep region zone woreda kebele ea hhid pid age male + collapse (first) age male, by(region zone woreda kebele ea hhid pid) + codebook male +tempfile members +save `members', replace + +// Generate long files +// Joaquin 03.16.23: Use all above labor tempfiles to generate: plot_labor_long.dta, plot_labor.dta, hh_cost_labor.dta +use `postplanting_family', clear +append using `postharvesting_family' +preserve + bysort hhid holder_id parcel_id field_id season: gen dup = cond(_N==1,0,_n) + tab dup +restore +reshape long pid weeks_worked days_week, i(hhid holder_id parcel_id field_id season) j(colid) string +gen days=weeks_worked*days_week +drop if days==. +merge m:1 hhid pid using `members', nogen keep(1 3) +gen gender="child" if age<16 +replace gender="male" if strmatch(gender,"") & male==1 +replace gender="female" if strmatch(gender,"") & male==0 +gen labor_type="family" +keep region zone woreda kebele ea hhid holder_id parcel_id field_id season gender days labor_type +// Joaquin 034.03.23: The is no *exchange labor* in ETH W3. +foreach i in region zone woreda kebele ea hhid { + merge m:1 `i' gender season using `wage_`i'_median', nogen keep(1 3) +} + merge m:1 gender season using `wage_country_median', nogen keep(1 3) // + gen wage=wage_hhid +foreach i in region zone woreda kebele ea { + replace wage = wage_`i' if obs_`i' > 9 +} +egen wage_sd = sd(wage_hhid), by(gender season) +egen mean_wage = mean(wage_hhid), by(gender season) +/* The below code assumes that wages are normally distributed and values below the 0.15th percentile and above the 99.85th percentile are outliers, keeping the median values for the area in those instances. +In reality, what we see is that it trims a significant amount of right skew - the max value is 14 stdevs above the mean while the min is only 1.15 below. +*/ +replace wage=wage_hhid if wage_hhid !=. & abs(wage_hhid-mean_wage)/wage_sd <3 //Using household wage when available, but omitting implausibly high or low values. Trims about 5,000 hh obs, max goes from 80,000->35,000; mean 3,300 -> 2,600 + +gen val = wage*days +append using `all_hired' +keep hhid holder_id parcel_id field_id season days val labor_type gender number +drop if val==.&days==. +//ALT QUICK FIX +ren hhid household_id +merge m:1 household_id holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers", nogen keep(1 3) keepusing(dm_gender) +ren household_id hhid +codebook dm_gender // No missing values for dm_gender. +// APN 05.02.24: No missing values for dm_gender. Commenting out the codes the preserve-restore checks if the hhs with missing dm_gender are part of the hh module. +/* keep if dm_gender==. + recode dm_gender (.=4) + collapse (first) dm_gender, by(hhid) + tab dm_gender + merge 1:1 hhid using "${Ethiopia_ESS_W3_created_data}/Ethiopia_ESS_W3_hhids.dta" // Joaquin 04.05.23: HHs with dm_gender missing are not part of the hh module. +restore +*/ +replace dm_gender = 1 if dm_gender==. // Joaquin 07.07.23: Imputing male for dm_gender missing values + +collapse (sum) number val days, by(hhid holder_id parcel_id field_id season labor_type gender dm_gender) //this is a little confusing, but we need "gender" and "number" for the agwage file. + la var gender "Gender of worker" + la var dm_gender "Plot manager gender" + la var labor_type "Hired, exchange, or family labor" + la var days "Number of person-days per plot" + la var val "Total value of hired labor (Naira)" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_labor_long.dta",replace + +preserve + collapse (sum) labor_=days, by (hhid holder_id parcel_id field_id labor_type) + reshape wide labor_, i(hhid holder_id parcel_id field_id) j(labor_type) string + la var labor_family "Number of family person-days spent on plot, all seasons" + la var labor_nonhired "Number of exchange (free) person-days spent on plot, all seasons" + la var labor_hired "Number of hired labor person-days spent on plot, all seasons" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_labor_days.dta",replace //AgQuery +restore + +preserve + gen exp="exp" if strmatch(labor_type,"hired") + replace exp="imp" if strmatch(exp,"") + //append using `inkind_payments' + collapse (sum) val, by(hhid holder_id parcel_id field_id exp dm_gender) + codebook dm_gender + gen input="labor" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_labor.dta", replace //this gets used below. +restore + +//And now we go back to wide +collapse (sum) val, by(hhid holder_id parcel_id field_id season labor_type dm_gender) +ren val val_ +reshape wide val_, i(hhid holder_id parcel_id field_id season dm_gender) j(labor_type) string +ren val* val*_ +reshape wide val*, i(hhid holder_id parcel_id field_id dm_gender) j(season) string +gen dm_gender2 = "male" if dm_gender==1 +replace dm_gender2 = "female" if dm_gender==2 +replace dm_gender2 = "mixed" if dm_gender==3 +drop dm_gender +codebook dm_gender2 +ren val* val*_ +reshape wide val*, i(hhid holder_id parcel_id field_id) j(dm_gender2) string +collapse (sum) val*, by(hhid) +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_labor.dta", replace + +****************************************************** *************************** +* CHEMICALS, FERTILIZER, LAND, ANIMALS, AND MACHINES * // Added Joaquin 03.14.2023 +****************************************************** *************************** + *** Pesticides/Herbicides/Animals/Machines +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_w4.dta", clear // APN 05.08.2024: The ESS W5 module also contains qty and unit of pesticide, herbicide, fungicide used. + rename saq01 region + rename saq02 zone + rename saq03 woreda + rename saq06 kebele + rename saq07 ea + ren household_id hhid + + ren s4q01b crop_code + rename s4q05 usepestexp // Pesticide dummy + rename s4q07 usefungexp // Fungicide dummy + rename s4q06 useherbexp // Herbicide dummy + + ren s4q05a qtypestexp + ren s4q05b unitpestexp + ren s4q06a qtyherbexp + ren s4q06b unitherbexp + ren s4q07a qtyfungexp + ren s4q7b unitfungexp + + foreach i in herbexp pestexp fungexp { + replace qty`i'=qty`i'/1000 if unit`i'==3 & qty`i'>9 //Many people reporting 1-5 grams of pesticide/herbicide on their plot - assuming this is likely a typo (and values bear this out) //APN 05. 08. 2024 - Lots of respondents also reporting 0.25 - 8 grams of pesticide/herbicide in ESS W5 too. + replace unit`i'=1 if unit`i'==3 + } + + + unab vars : *exp + local stubs : subinstr local vars "exp" "", all + display "`stubs'" + gen dummya = 1 + gen dummyb = sum(dummya) + drop dummya + reshape long `stubs', i(hhid holder_id parcel_id field_id crop_code dummyb) j(exp) string + gen dummyc = sum(dummyb) + drop dummyb + reshape long use qty unit, i(hhid holder_id parcel_id field_id crop_code dummyc) j(input) string + recode use (2=.) + collapse (sum) use qty unit, by(hhid holder_id parcel_id field_id input exp ) + replace use = 1 if use>=2 + //gen itemcode = 1 // Dummy variable +/* gen qty = . // JM 09.11.23: The module does not have information on quantity used + gen unit = . // JM 09.11.23: The module does not have information on quantity used + */ + tempfile field_inputs + save `field_inputs' + + ** plot_inputs + + ***Fertilizer + + ** phys_unouts +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_w4.dta", clear // Joaquin 04.06.23: This module contains fertilizer info. + + // Urea + gen usefertexp1 = 1 if s3q21==1 + //gen itemcodefertexp = 1 if usefertexp1 == 1 + gen qtyfertexp1 = s3q21a + gen unitfertexp1 = 1 if s3q21==1 // Qty is in kilos + gen valfertexp1 = s3q21d if s3q21==1 + replace valfertexp1 = subinstr(valfertexp1, ",", ".", 1) + replace valfertexp1 = subinstr(valfertexp1, "o", "0", 1) + destring valfertexp1, replace + + // DAP + gen usefertexp2 = 1 if s3q22==1 + //gen itemcodefertexpexp = 2 if usefertexpexp2 == 1 + gen qtyfertexp2 = s3q22a + gen unitfertexp2 = 1 if s3q22==1 // Qty is in kilos + gen valfertexp2 = s3q22d if s3q22==1 + + // NPS + gen usefertexp3 = 1 if s3q23==1 + //gen itemcodefertexpexp = 3 if usefertexpexp3 == 1 + gen qtyfertexp3 = s3q23a + gen unitfertexp3 = 1 if s3q23==1 // Qty is in kilos + gen valfertexp3 = s3q23d if s3q23==1 + + // Other inorganic fertexpilizer + gen usefertexp4 = 1 if s3q24==1 + //gen itemcodefertexpexp = 4 if usefertexpexp4 == 1 + gen qtyfertexp4 = s3q24a + gen unitfertexp4 = 1 if s3q24==1 // Qty is in kilos + gen valfertexp4 = s3q24d if s3q24==1 + + // Manure + gen usefertexp5 = 1 if s3q25==1 // No qty. Just dummy + //gen itemcodefertexpexp = 5 if usefertexpexp5 == 1 + + // Compost + gen usefertexp6 = 1 if s3q26==1 + //gen itemcodefertexpexp = 6 if usefertexpexp6 == 1 + + // Other organic + gen usefertexp7 = 1 if s3q27==1 + //gen itemcodefertexpexp = 7 if usefertexpexp7 == 1 + + /* + label var itemcodefertexp1 "Urea" + label var itemcodefertexp2 "DAP" + label var itemcodefertexp3 "NPS" + label var itemcodefertexp4 "Other inorganic" + label var itemcodefertexp5 "Manure" + label var itemcodefertexp6 "Compost" + label var itemcodefertexp7 "Other organic" + */ + ren household_id hhid + keep use* qty* unit* val* hhid holder_id parcel_id field_id + gen dummya=1 + gen dummyb=sum(dummya) //dummy id for duplicates + drop dummya + unab vars : *1 + local stubs : subinstr local vars "1" "", all + display "`stubs'" + reshape long `stubs', i(hhid holder_id parcel_id field_id dummyb) j(itemcode) + drop if (usefertexp==.) + gen dummyc=sum(dummyb) + drop dummyb + unab vars2 : *exp + local stubs2 : subinstr local vars2 "exp" "", all + display "`stubs2'" + reshape long `stubs2', i(hhid holder_id parcel_id field_id itemcode dummyc) j(exp) string + gen dummyd = sum(dummyc) + drop dummyc + reshape long use qty unit val, i(hhid holder_id parcel_id field_id itemcode exp dummyd) j(input) string + //collapse (sum) qty* val*, by(hhid holder_id parcel_id field_id itemcode use) + drop dummyd + label define itemcodefert 1 "Urea" 2 "DAP" 3 "NPS" 4 "Other inorganic" 5 "Manure" 6 "Compost" 7 "Other organic" + label values itemcode itermcodefert + replace input = "inorg" if itemcode>=1 & itemcode<=4 + replace input = "orgfert" if itemcode>=5 & itemcode<=7 + //replace unit=0 if unit==. // unit==1 <=> kg + tempfile phys_inputs + save `phys_inputs' + + ** fieldrents + use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear + sort hhid holder_id parcel_id field_id + bysort hhid holder_id parcel_id field_id: gen dup = cond(_N==1,0,_n) + collapse (first) field_size ha_planted (sum) value_harvest, by(hhid holder_id parcel_id field_id) //APN 05.02.2024: using field_size instead of area_meas_hectares - Field area measured in hectares + ren field_size area_meas_hectares // APN.05.3.2024 Changing field size to area_meas_hectares + merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", keep(1 3) keepusing(cultivated) nogen + + preserve + use "$Ethiopia_ESS_W4_temp_data/sect2_pp_w4.dta", clear + ren household_id hhid + // Joaquin 04.26: NGA at plot level, ETH is parcel level. We need field-level data. + // Joaquin 04.26: Perhaps distribute price evenly across fields? Ask what to do about this. + // Andrew 5/3/2023 : Imputations + egen valparrentexp = rowtotal(s2q10a s2q10b) + // Joaquin 05.24.23: Need to add the share of payments + keep hhid holder_id parcel_id valparrentexp s2q10c + tempfile parcelrents + save `parcelrents', replace + gen rental_cost_land = valparrentexp + drop valparrentexp s2q10c + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_rental_parcel.dta", replace + restore + + merge m:1 hhid holder_id parcel_id using `parcelrents', nogen + + bysort hhid holder_id parcel_id: egen area_meas_hectares_parcel = sum(area_meas_hectares) + gen qtyfieldrentexp= area_meas_hectares if (valparrentexp>0 & valparrentexp!=.) | (s2q10c>0 & s2q10c!=.) + gen valfieldrentexp = (area_meas_hectares/area_meas_hectares_parcel)*valparrentexp if valparrentexp>0 & valparrentexp!=. + replace valfieldrentexp = valfieldrentexp + (s2q10c/100)*value_harvest if valfieldrentexp!=. & s2q10c!=. & value_harvest!=. + replace valfieldrentexp = (s2q10c/100)*value_harvest if valfieldrentexp==. & s2q10c!=. & value_harvest!=. + + gen qtyfieldrentimp = area_meas_hectares if qtyfieldrentexp==. + replace qtyfieldrentimp = ha_planted if qtyfieldrentimp==. & qtyfieldrentexp==. + + keep if cultivate==1 //No need for uncultivated plots + keep hhid holder_id parcel_id field_id qtyfieldrentexp* valfieldrentexp* + + gen usefieldrentexp = (qtyfieldrentexp>0 & qtyfieldrentexp!=.) + + reshape long usefieldrent valfieldrent qtyfieldrent, i(hhid holder_id parcel_id field_id) j(exp) string + reshape long use val qty, i(hhid holder_id parcel_id field_id exp) j(input) string + + gen unit=(qty!=. & val!=.) + gen itemcode=1 //dummy var + tempfile fieldrents + save `fieldrents' + + ** seeds // JM 06.04.23: We will just generate the necessary variables with missing values. We will use "${Ethiopia_ESS_W3_temp_data}/Post-Planting/sect4_pp_w4.dta" to get use_imprv_seed for person_ids. + + use "${Ethiopia_ESS_W4_temp_data}/sect4_pp_w4.dta", clear // Joaquin 04.06.23: This module contains seed info. Seed use at field level. Only seed use. + // Andrew 5/3/2023: AgQuery+ does not track seed expenses + // Generate variables with missing for where infromation is missing + // We care about improved seed + gen itemcode = s4q11 // APN.05.03.2024 - traditional==1, improved==2 new, 3==improved saved from last year, 4==improved from last year production I will code options 2 - 4 as improved seeds. + drop if itemcode==. + ren household_id hhid + gen exp = "exp" if itemcode==1 | itemcode==2 + replace exp = "imp" if itemcode==3 | itemcode==4 + gen use = (itemcode!=.) + gen qty = s4q11a if s4q11a!=. /*& s4q11b==.*/ //APN.05.03.2024 - ESS W5 collected quantity of improved seeds only in kilograms +* replace qty = pp_s4q11b_b/1000 if pp_s4q11b_a==. & pp_s4q11b_b!=. +* replace qty = pp_s4q11b_a + pp_s4q11b_b/1000 if pp_s4q11b_a!=. & pp_s4q11b_b!=. + gen unit = 1 if qty!=. // 1 == kg + gen val = s4q12 // JM 09.11.23: Value is available ONLY for improved seeds + gen input = "seeds" if use==1 + collapse (sum) use val qty, by(hhid holder_id parcel_id field_id exp input itemcode unit) + replace qty = . if qty==0 & use==1 + replace val = . if exp!="exp" + drop if itemcode ==. + //recode val (.=0) // Joaquin 6.12.23: Added this line-faq + + * Append // Joaquin 6.12.23: Added this sub-subsection + + append using `fieldrents' + append using `field_inputs' + append using `phys_inputs' + + + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta",nogen keep(1 3) keepusing(weight) + merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", nogen keep(1 3) keepusing(area_meas_hectares) + //ALT TEMP FIX + ren hhid household_id + merge m:1 household_id holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers",nogen keep(1 3) keepusing(dm_gender) + ren household_id hhid + replace dm_gender = 1 if dm_gender == . // Joaquin 7.7.23: Obs are not presenst in field_decision_maker + tempfile all_field_inputs + merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) keepusing(region zone woreda kebele ea) // Joaquin 7.6.23: Added to get variables: region zone woreda kebele ea + preserve + keep use unit val qty weight area_meas_hectares dm_gender region zone woreda kebele ea + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_use_dummies.dta", replace + restore + + tempfile all_field_inputs + save `all_field_inputs' + + keep if strmatch(exp,"exp") // & qty!=. //Now for geographic medians + gen fieldweight = weight*area_meas_hectares // Joaquin 6.12.23: Q for Andrew: use weight or weight_pop_rururb? + //recode val (0=.) // JM 09.11.23: Most of our use variables are binary. doing the recode would erase most of them. + //drop if unit==0 //Remove things with unknown units. + gen price = val/qty if val!=. & qty!=. & qty>0 + drop if price==. + gen obs=1 + + foreach i in region zone woreda kebele ea hhid { + preserve + bys `i' input unit itemcode : egen obs_`i' = sum(obs) + collapse (median) price_`i'=price [aw=fieldweight], by (`i' input unit itemcode obs_`i') + tempfile price_`i'_median + save `price_`i'_median' + restore + } + + preserve + bys input unit itemcode : egen obs_country = sum(obs) + collapse (median) price_country = price [aw=fieldweight], by(input unit itemcode obs_country) + tempfile price_country_median + save `price_country_median' + restore + + use `all_field_inputs',clear + foreach i in region zone woreda kebele ea hhid { + merge m:1 `i' input unit itemcode using `price_`i'_median', nogen keep(1 3) + } + merge m:1 input unit itemcode using `price_country_median', nogen keep(1 3) + *recode hhid (.=0) + gen price=price_hhid + foreach i in country region zone woreda kebele ea hhid { + replace price = price_`i' if obs_`i' > 9 & obs_`i'!=. + } + //Default to household prices when available + replace price = price_hhid if price_hhid>0 + //replace qty = 0 if qty <0 //4 households reporting negative quantities of fertilizer. + //recode val qty (.=0) + //drop if val==0 & qty==0 //Dropping unnecessary observations. + replace val=qty*price if val==0 & qty!=. & qty>0 + //replace input = "orgfert" if input=="" itemcode>=5 & itemcode<=7 // JM 7.6.23: Look for itemcode for organic fertilizer + //replace input = "inorg" if strmatch(input,"fert") + tab input + preserve + //Need this for quantities and not sure where it should go. + keep if strmatch(input,"orgfert") | strmatch(input,"inorg") | strmatch(input,"herb") | strmatch(input,"pest") | strmatch(input,"fung") + //Unfortunately we have to compress liters and kg here, which isn't ideal. + *collapse (sum) use_=use qty_=qty, by(hhid holder_id parcel_id field_id input) //APN 05.10.2024 - Check with Didier + collapse (max) use_=use (sum) qty_=qty, by(hhid holder_id parcel_id field_id input) + reshape wide use_ qty_, i(hhid holder_id parcel_id field_id) j(input) string + recode use_* (.=0) + ren qty_inorg fert_inorg_rate + ren qty_orgfert fert_org_rate + ren qty_herb herb_rate + ren qty_pest pest_rate + ren qty_fung fung_rate + + la var fert_inorg_rate "Qty inorganic fertilizer used (kg)" + la var fert_org_rate "Qty organic fertilizer used (kg)" + la var herb_rate "Qty of herbicide used (kg/L)" + la var pest_rate "Qty of pesticide used (kg/L)" + la var fung_rate "Qty of fungicide used (kg/L)" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_quantities.dta", replace + /* + use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_quantities.dta", clear + JM 09.11.23: Need to create "use_input" variables as dummies. qty_input does not account for bin ary information. + */ + restore + + /* + use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_quantities.dta", clear + */ + + append using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_labor.dta" + collapse (sum) val, by (hhid holder_id parcel_id field_id exp input dm_gender) + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs_long.dta",replace + + preserve + collapse (sum) val, by(hhid exp input) + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_inputs_long.dta", replace //ALT 02.07.2022: Holdover from W4. + restore + + preserve + collapse (sum) val_=val, by(hhid holder_id parcel_id field_id exp dm_gender) + drop if exp=="" //CHECK - APN 05.03.2024 :Dropped missing values for exp + reshape wide val_, i(hhid holder_id parcel_id field_id dm_gender) j(exp) string + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs.dta", replace //This gets used below. + restore + + //This version of the code retains identities for all inputs; not strictly necessary for later analyses. + ren val val_ + drop if exp=="" //CHECK - APN 05.03.2024 :Dropped missing values for exp + reshape wide val_, i(hhid holder_id parcel_id field_id exp dm_gender) j(input) string + ren val* val*_ + reshape wide val*, i(hhid holder_id parcel_id field_id dm_gender) j(exp) string + gen dm_gender2 = "male" if dm_gender==1 + replace dm_gender2 = "female" if dm_gender==2 + replace dm_gender2 = "mixed" if dm_gender==3 + drop dm_gender + ren val* val*_ + reshape wide val*, i(hhid holder_id parcel_id field_id) j(dm_gender2) string + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs_wide.dta", replace //Used for monocrop plots + collapse (sum) val*, by(hhid) + + unab vars3 : *_exp_male //just get stubs from one + local stubs3 : subinstr local vars3 "_exp_male" "", all + foreach i in `stubs3' { + egen `i'_exp_hh = rowtotal(`i'_exp_male `i'_exp_female `i'_exp_mixed) + egen `i'_imp_hh=rowtotal(`i'_exp_hh `i'_imp_male `i'_imp_female `i'_imp_mixed) + } + egen val_exp_hh=rowtotal(*_exp_hh) + egen val_imp_hh=rowtotal(*_imp_hh) + //drop /*val_mech_imp**/ val_seedtrans_imp* val_transfert_imp* val_feedanml_imp* //Not going to have any data + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_inputs_verbose.dta", replace + + + //We can do this more simply by: + use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs_long.dta", clear + //back to wide + drop input + codebook dm_gender + drop if exp=="" + collapse (sum) val, by(hhid holder_id parcel_id field_id exp dm_gender) + gen dm_gender2 = "male" if dm_gender==1 + replace dm_gender2 = "female" if dm_gender==2 + replace dm_gender2 = "mixed" if dm_gender==3 + drop dm_gender + codebook dm_gender2 + ren val* val*_ + reshape wide val*, i(hhid holder_id parcel_id field_id dm_gender2) j(exp) string + ren val* val*_ + + preserve // Get planted area + use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta",clear + collapse (sum) ha_planted, by(hhid holder_id parcel_id field_id) + tempfile planted_area + save `planted_area' + restore + + merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", nogen keep(1 3) keepusing(area_meas_hectares) //do per-ha expenses at the same time + merge 1:1 hhid holder_id parcel_id field_id using `planted_area', nogen keep(1 3) + reshape wide val*, i(hhid holder_id parcel_id field_id) j(dm_gender2) string + collapse (sum) val* area_meas_hectares ha_planted*, by(hhid) + //Renaming variables to plug into later steps + foreach i in male female mixed { + gen cost_expli_`i' = val_exp_`i' + egen cost_total_`i' = rowtotal(val_exp_`i' val_imp_`i') + } + egen cost_expli_hh = rowtotal(val_exp*) + egen cost_total_hh = rowtotal(val*) + drop val* + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_inputs.dta", replace + + +******************************************************************************** +*MONOCROPPED PLOTS* +******************************************************************************** +**# Bookmark #3 + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear + keep if purestand==1 & relay!=1 //For now, omitting relay crops. + ren crop_code_master cropcode +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_monocrop_plots.dta", replace + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear + keep if purestand==1 & relay!=1 //For now, omitting relay crops. + // merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_decision_makers.dta", nogen keep(1 3) keepusing(dm_gender) // MGM 4.30.2024: I already have dm_gender in my all fields. + ren crop_code_master cropcode + ren ha_planted monocrop_ha + ren quant_harv_kg kgs_harv_mono + ren value_harvest val_harv_mono + + +forvalues k=1(1)$nb_topcrops { +preserve + local c : word `k' of $topcrop_area + local cn : word `k' of $topcropname_area + local cn_full : word `k' of $topcropname_area_full + keep if cropcode==`c' + ren monocrop_ha `cn'_monocrop_ha + drop if `cn'_monocrop_ha==0 + ren kgs_harv_mono kgs_harv_mono_`cn' + ren val_harv_mono val_harv_mono_`cn' + gen `cn'_monocrop=1 + la var `cn'_monocrop "HH grows `cn_full' on a monocropped plot" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_`cn'_monocrop.dta", replace + + foreach i in `cn'_monocrop_ha kgs_harv_mono_`cn' val_harv_mono_`cn' { + gen `i'_male = `i' if dm_gender==1 + gen `i'_female = `i' if dm_gender==2 + gen `i'_mixed = `i' if dm_gender==3 + } + + la var `cn'_monocrop_ha "Total `cn' monocrop hectares - Household" + la var `cn'_monocrop "Household has at least one `cn' monocrop" + la var kgs_harv_mono_`cn' "Total kilograms of `cn' harvested - Household" + la var val_harv_mono_`cn' "Value of harvested `cn' (Birr)" + foreach g in male female mixed { + la var `cn'_monocrop_ha_`g' "Total `cn' monocrop hectares on `g' managed plots - Household" + la var kgs_harv_mono_`cn'_`g' "Total kilograms of `cn' harvested on `g' managed plots - Household" + la var val_harv_mono_`cn'_`g' "Total value of `cn' harvested on `g' managed plots - Household" + } + collapse (sum) *monocrop* (sum) kgs_harv* val_harv*, by(hhid) + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_`cn'_monocrop_hh_area.dta", replace +restore +} + + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs_long.dta", clear +foreach cn in $topcropname_area { +preserve + keep if strmatch(exp, "exp") + drop exp + levelsof input, clean l(input_names) + ren val val_ + reshape wide val_, i(hhid holder_id parcel_id field_id dm_gender) j(input) string + ren val* val*_`cn'_ + gen dm_gender2 = "male" if dm_gender==1 + replace dm_gender2 = "female" if dm_gender==2 + replace dm_gender2 = "mixed" if dm_gender==3 + drop dm_gender + reshape wide val*, i(hhid holder_id parcel_id field_id) j(dm_gender2) string + merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_`cn'_monocrop.dta", nogen keep(3) + collapse (sum) val*, by(hhid) + foreach i in `input_names' { + egen val_`i'_`cn'_hh = rowtotal(val_`i'_`cn'_male val_`i'_`cn'_female val_`i'_`cn'_mixed) + } + //To do: labels + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_inputs_`cn'.dta", replace +restore +} + + +******************************************************************************** +*LIVESTOCK INCOME +******************************************************************************** +*BET 05.26.2021 +*Expenses +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_w4.dta", clear +append using "$Ethiopia_ESS_W4_temp_data/sect8_3_ls_w4.dta" +append using "$Ethiopia_ESS_W4_temp_data/sect8_2_ls_w4.dta" +ren ls_s8_3q11 cost_water_livestock +ren ls_s8_3q14 cost_fodder_livestock +ren ls_s8_3q22 cost_vaccines_livestock +ren ls_s8_3q24 cost_treatment_livestock +ren ls_s8_3q04 cost_breeding_livestock +recode cost_water_livestock cost_fodder_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock (.=0) + +*Dairy costs +preserve +keep if ls_type == 1 +collapse (sum) cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock, by (household_id) +egen cost_lrum = rowtotal (cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock) +keep household_id cost_lrum +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_lrum_expenses", replace +restore + +preserve +ren ls_type livestock_code +gen species = (inlist(livestock_code,1)) + 2*(inlist(livestock_code,2)) + 3*(livestock_code==3) + 4*(livestock_code==5) + 5*(inlist(livestock_code,4)) recode species (0=.) la def species 1 "Large ruminants" 2 "Small ruminants" 3 "Camels" 4 "Equine" 5 "Poultry" la val species species @@ -1053,7 +2464,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_expenses", repla *Note that costs for hired labor are not captured. *Livestock products -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_w4.dta", clear ren ls_code livestock_code ren ls_s8_4_q02 animals_milked @@ -1077,7 +2488,7 @@ ren ls_s8_4q19 earnings_egg_sales gen price_per_egg = earnings_egg_sales / eggs_sold merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) -keep household_id weight region zone woreda kebele ea livestock_code milk_liters_produced price_per_liter eggs_produced price_per_egg earnings_milk_products /* +keep household_id weight_pop_rururb region zone woreda kebele ea livestock_code milk_liters_produced price_per_liter eggs_produced price_per_egg earnings_milk_products /* */earnings_milk_week months_milked earnings_egg_sales liters_sold_week eggs_sold gen price_per_unit = price_per_liter replace price_per_unit = price_per_egg if price_per_unit==. @@ -1092,7 +2503,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products", cle keep if price_per_unit !=. gen observation = 1 bys region zone woreda kebele livestock_code: egen obs_kebele = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone woreda kebele livestock_code obs_kebele) +collapse (median) price_per_unit [aw=weight_pop_rururb], by (region zone woreda kebele livestock_code obs_kebele) ren price_per_unit price_median_kebele lab var price_median_kebele "Median price per unit for this livestock product in the kebele" lab var obs_kebele "Number of sales observations for this livestock product in the kebele" @@ -1101,7 +2512,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products", cle keep if price_per_unit !=. gen observation = 1 bys region zone woreda livestock_code: egen obs_woreda = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone woreda livestock_code obs_woreda) +collapse (median) price_per_unit [aw=weight_pop_rururb], by (region zone woreda livestock_code obs_woreda) ren price_per_unit price_median_woreda lab var price_median_woreda "Median price per unit for this livestock product in the woreda" lab var obs_woreda "Number of sales observations for this livestock product in the woreda" @@ -1110,7 +2521,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products", cle keep if price_per_unit !=. gen observation = 1 bys region zone livestock_code: egen obs_zone = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone livestock_code obs_zone) +collapse (median) price_per_unit [aw=weight_pop_rururb], by (region zone livestock_code obs_zone) ren price_per_unit price_median_zone lab var price_median_zone "Median price per unit for this livestock product in the zone" lab var obs_zone "Number of sales observations for this livestock product in the zone" @@ -1119,7 +2530,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products", cle keep if price_per_unit !=. gen observation = 1 bys region livestock_code: egen obs_region = count(observation) -collapse (median) price_per_unit [aw=weight], by (region livestock_code obs_region) +collapse (median) price_per_unit [aw=weight_pop_rururb], by (region livestock_code obs_region) ren price_per_unit price_median_region lab var price_median_region "Median price per unit for this livestock product in the region" lab var obs_region "Number of sales observations for this livestock product in the region" @@ -1128,7 +2539,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products", cle keep if price_per_unit !=. gen observation = 1 bys livestock_code: egen obs_country = count(observation) -collapse (median) price_per_unit [aw=weight], by (livestock_code obs_country) +collapse (median) price_per_unit [aw=weight_pop_rururb], by (livestock_code obs_country) ren price_per_unit price_median_country lab var price_median_country "Median price per unit for this livestock product in the country" lab var obs_country "Number of sales observations for this livestock product in the country" @@ -1167,7 +2578,7 @@ lab var earnings_milk_products "Earnings from milk products sold (gross earnings save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products", replace *Sales (live animals) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_2_ls_w4.dta", clear ren ls_code livestock_code ren ls_s8_2q13 number_sold ren ls_s8_2q14 income_live_sales @@ -1188,7 +2599,7 @@ recode price_per_animal (0=.) merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" drop if _merge==2 drop _merge -keep household_id weight region zone woreda kebele ea livestock_code number_sold income_live_sales number_slaughtered income_slaughtered price_per_animal value_livestock_purchase +keep household_id weight_pop_rururb region zone woreda kebele ea livestock_code number_sold income_live_sales number_slaughtered income_slaughtered price_per_animal value_livestock_purchase save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", replace *Implicit prices @@ -1196,7 +2607,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", clear keep if price_per_animal !=. gen observation = 1 bys region zone woreda kebele livestock_code: egen obs_kebele = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone woreda kebele livestock_code obs_kebele) +collapse (median) price_per_animal [aw=weight_pop_rururb], by (region zone woreda kebele livestock_code obs_kebele) ren price_per_animal price_median_kebele lab var price_median_kebele "Median price per unit for this livestock in the kebele" lab var obs_kebele "Number of sales observations for this livestock in the kebele" @@ -1205,7 +2616,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", clear keep if price_per_animal !=. gen observation = 1 bys region zone woreda livestock_code: egen obs_woreda = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone woreda livestock_code obs_woreda) +collapse (median) price_per_animal [aw=weight_pop_rururb], by (region zone woreda livestock_code obs_woreda) ren price_per_animal price_median_woreda lab var price_median_woreda "Median price per unit for this livestock in the woreda" lab var obs_woreda "Number of sales observations for this livestock in the woreda" @@ -1214,7 +2625,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", clear keep if price_per_animal !=. gen observation = 1 bys region zone livestock_code: egen obs_zone = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone livestock_code obs_zone) +collapse (median) price_per_animal [aw=weight_pop_rururb], by (region zone livestock_code obs_zone) ren price_per_animal price_median_zone lab var price_median_zone "Median price per unit for this livestock in the zone" lab var obs_zone "Number of sales observations for this livestock in the zone" @@ -1223,7 +2634,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", clear keep if price_per_animal !=. gen observation = 1 bys region livestock_code: egen obs_region = count(observation) -collapse (median) price_per_animal [aw=weight], by (region livestock_code obs_region) +collapse (median) price_per_animal [aw=weight_pop_rururb], by (region livestock_code obs_region) ren price_per_animal price_median_region lab var price_median_region "Median price per unit for this livestock in the region" lab var obs_region "Number of sales observations for this livestock in the region" @@ -1232,7 +2643,7 @@ use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales", clear keep if price_per_animal !=. gen observation = 1 bys livestock_code: egen obs_country = count(observation) -collapse (median) price_per_animal [aw=weight], by (livestock_code obs_country) +collapse (median) price_per_animal [aw=weight_pop_rururb], by (livestock_code obs_country) ren price_per_animal price_median_country lab var price_median_country "Median price per unit for this livestock in the country" lab var obs_country "Number of sales observations for this livestock in the country" @@ -1262,7 +2673,7 @@ lab var value_livestock_purchases "Value of livestock purchases (seems to span o save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_sales", replace *TLU (Tropical Livestock Units) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_2_ls_W4.dta", clear gen tlu=0.5 if (ls_code==1|ls_code==2|ls_code==3|ls_code==4|ls_code==5|ls_code==6) replace tlu=0.1 if (ls_code==7|ls_code==8) replace tlu=0.7 if (ls_code==9) @@ -1336,7 +2747,7 @@ drop tlu_coefficient nb_ls_born nb_ls_purchased nb_ls_gifts_received nb_ls_gifts save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_Coefficients.dta", replace *TLU (Tropical Livestock Units) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_2_ls_W4.dta", clear gen tlu=0.5 if (ls_code==1|ls_code==2|ls_code==3|ls_code==4|ls_code==5|ls_code==6) replace tlu=0.1 if (ls_code==7|ls_code==8) replace tlu=0.7 if (ls_code==9) @@ -1371,7 +2782,7 @@ gen tlu_1yearago = number_1yearago * tlu_coefficient *Livestock mortality rate ren livestock_code ls_code -merge m:1 ls_code household_id holder_id using "$Ethiopia_ESS_W4_raw_data/sect8_1_ls_W4.dta", nogen +merge m:1 ls_code household_id holder_id using "$Ethiopia_ESS_W4_temp_data/sect8_1_ls_W4.dta", nogen ren ls_code livestock_code replace number_today = ls_s8_1q01 gen tlu_today = number_today * tlu_coefficient @@ -1456,41 +2867,41 @@ lab var value_today "Value of livestock holdings today" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU.dta", replace ******************************************************************************** -*LIVESTOCK INCOME - Long format recode (HI 7.14.22) +*LIVESTOCK INCOME - Long format recode (HI 2.22.22) ******************************************************************************** -// EXPENSES -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear // at ls_code level -append using "$Ethiopia_ESS_W4_raw_data/sect8_3_ls_w4.dta" // at ls_type level -append using "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_w4.dta" // at ls_code level +*Expenses +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_w4.dta", clear +append using "$Ethiopia_ESS_W4_temp_data/sect8_3_ls_w4.dta" +append using "$Ethiopia_ESS_W4_temp_data/sect8_2_ls_w4.dta" ren ls_s8_3q11 cost_water_livestock ren ls_s8_3q14 cost_fodder_livestock ren ls_s8_3q22 cost_vaccines_livestock ren ls_s8_3q24 cost_treatment_livestock ren ls_s8_3q04 cost_breeding_livestock recode cost_water_livestock cost_fodder_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock (.=0) -replace ls_type=1 if inrange(ls_code, 1,6) & ls_type==. // assigning ls_code for obs from first appended file. File also contains obs with ls_type and without ls_code - can't assign species. -HI 7/12/22 *Dairy costs preserve keep if ls_type == 1 -collapse (sum) cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock, by (household_id ls_code) +collapse (sum) cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock, by (household_id ls_type) egen cost_lrum = rowtotal (cost_fodder_livestock cost_water_livestock cost_vaccines_livestock cost_treatment_livestock cost_breeding_livestock) -keep household_id ls_code cost_lrum -ren ls_code livestock_code -la var cost_lrum "Fodder, water, vaccines, treatment, and breeding costs for large ruminants" +foreach i in lrum { + gen cost = cost_`i' +} +keep household_id ls_type cost save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_lrum_expenses_long", replace restore preserve -gen species = (inlist(ls_type,1)) + 2*(inlist(ls_type,2)) + 3*(ls_type==3) + 4*(ls_type==5) + 5*(inlist(ls_type,4)) +ren ls_type livestock_code +gen species = (inlist(livestock_code,1)) + 2*(inlist(livestock_code,2)) + 3*(livestock_code==3) + 4*(livestock_code==5) + 5*(inlist(livestock_code,4)) recode species (0=.) la def species 1 "Large ruminants" 2 "Small ruminants" 3 "Camels" 4 "Equine" 5 "Poultry" // no bees la val species species -collapse (sum) cost_vaccines_livestock cost_treatment_livestock, by (household_id ls_code) +collapse (sum) cost_vaccines_livestock cost_treatment_livestock, by (household_id species) gen ls_exp_vac = cost_vaccines_livestock + cost_treatment_livestock la var ls_exp_vac "Cost for vaccines and veterinary treatment for livestock" drop cost_vaccines_livestock cost_treatment_livestock -ren ls_code livestock_code save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_expenses_animal_long", replace restore @@ -1500,489 +2911,71 @@ lab var cost_fodder_livestock "Cost for fodder for livestock" lab var cost_vaccines_livestock "Cost for vaccines for livestock" lab var cost_treatment_livestock "Cost for veterinary treatment for livestock" lab var cost_breeding_livestock "Cost for breeding (insemination?) for livestock" -ren ls_code livestock_code save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_expenses_long", replace *Note that costs for hired labor are not captured. -// LIVESTOCK PRODUCTS -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear - -ren ls_code livestock_code -ren ls_s8_4_q02 animals_milked -ren ls_s8_4q03 months_milked -ren ls_s8_4q04 liters_per_day -recode animals_milked months_milked liters_per_day (.=0) -gen milk_liters_produced = (animals_milked * months_milked * 30 * liters_per_day) /* 30 days per month */ -ren ls_s8_4q10 earnings_milk_week -ren ls_s8_4q09 liters_sold_week -ren ls_s8_4q12 earnings_milk_products /* Note that we can't value the milk inputs here. They'll get double-counted as income */ -gen price_per_liter = earnings_milk_week / liters_sold_week - -*BET 05.26.2021 egg production is reported over 12 months, but egg sales are reported over 3 months -ren ls_s8_4q16 egg_laying_hens -ren ls_s8_4q14 clutching_periods -ren ls_s8_4q15 eggs_per_clutching_period -ren ls_s8_4q18 eggs_sold -recode egg_laying_hens clutching_periods eggs_per_clutching_period (.=0) -gen eggs_produced = (egg_laying_hens * clutching_periods * eggs_per_clutching_period) // BET 05.26.21 recall period for eggs produced in 12 months -ren ls_s8_4q19 earnings_egg_sales -gen price_per_egg = earnings_egg_sales / eggs_sold - -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) -keep household_id weight region zone woreda kebele ea livestock_code milk_liters_produced price_per_liter eggs_produced price_per_egg earnings_milk_products earnings_milk_week months_milked earnings_egg_sales liters_sold_week eggs_sold -/*gen price_per_unit = price_per_liter -replace price_per_unit = price_per_egg if price_per_unit==. -recode price_per_unit (0=.) */ -gen earnings_milk_year = earnings_milk_week*4*months_milked //assuming 4 weeks per month -gen liters_sold_year = liters_sold_week*4*months_milked -gen earnings_egg_sales_year = earnings_egg_sales*4 // BET 05.26.21 recall period for eggs sold is 3 months. this should be multiplied by 4 -gen eggs_sold_year = eggs_sold*4 // BET 05.26.21 recall period for eggs sold is 3 months. this should be multiplied by 4 -collapse (sum) months_milked liters_sold_week earnings_milk_week earnings_milk_products eggs_sold earnings_egg_sales milk_liters_produced eggs_produced earnings_milk_year liters_sold_year earnings_egg_sales_year eggs_sold_year (mean) price_per_liter price_per_egg, by(household_id livestock_code weight region zone woreda kebele ea) // collapsing milk/egg variables for all land holders in each household -replace months_milked = 12 if months_milked>12 // standardizing milking months within last year to 12 for households with multiple land holders who milked for a total of <12 months (HI 2.24.22) -ren milk_liters_produced produced1 -ren eggs_produced produced2 -ren price_per_liter price_per1 -ren price_per_egg price_per2 -ren earnings_milk_year earnings_year1 -ren earnings_egg_sales_year earnings_year2 -ren liters_sold_year sold_year1 -ren eggs_sold_year sold_year2 - -reshape long produced price_per earnings_year sold_year, i(household_id livestock_code) j(livestock_product) //cannot collapse earnings_milk_products and earnings_egg_sales - different time frames for each. HI 3.3.22 -la def livestock_product 1 "Milk" 2 "Eggs" -la val livestock_product livestock_product -replace months_milked =. if livestock_product==2 | inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16) -replace liters_sold_week =. if livestock_product==2 | inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16) -replace earnings_milk_week =. if livestock_product==2 | inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16) -replace earnings_milk_products =. if livestock_product==2 | inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16) -replace earnings_egg_sales =. if livestock_product==1 | livestock_code!=11 -replace eggs_sold =. if livestock_product==1 | livestock_code!=11 - -ren price_per price_per_unit -lab var produced "Liters of milk or number of eggs produced in last year" -lab var earnings_year "Annual earnings from milk/eggs" -lab var sold_year "Liters of milk or number of eggs sold in last year" -lab var price_per_unit "Price per liter of milk or per egg" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", replace - -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -keep if price_per_unit !=. -gen observation = 1 -bys region zone woreda kebele livestock_code: egen obs_kebele = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone woreda kebele livestock_code livestock_product obs_kebele) -ren price_per_unit price_median_kebele -lab var price_median_kebele "Median price per unit for this livestock product in the kebele" -lab var obs_kebele "Number of sales observations for this livestock product in the kebele" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_kebele_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -keep if price_per_unit !=. -gen observation = 1 -bys region zone woreda livestock_code: egen obs_woreda = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone woreda livestock_code livestock_product obs_woreda) -ren price_per_unit price_median_woreda -lab var price_median_woreda "Median price per unit for this livestock product in the woreda" -lab var obs_woreda "Number of sales observations for this livestock product in the woreda" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_woreda_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -keep if price_per_unit !=. -gen observation = 1 -bys region zone livestock_code: egen obs_zone = count(observation) -collapse (median) price_per_unit [aw=weight], by (region zone livestock_code livestock_product obs_zone) -ren price_per_unit price_median_zone -lab var price_median_zone "Median price per unit for this livestock product in the zone" -lab var obs_zone "Number of sales observations for this livestock product in the zone" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_zone_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -keep if price_per_unit !=. -gen observation = 1 -bys region livestock_code: egen obs_region = count(observation) -collapse (median) price_per_unit [aw=weight], by (region livestock_code livestock_product obs_region) -ren price_per_unit price_median_region -lab var price_median_region "Median price per unit for this livestock product in the region" -lab var obs_region "Number of sales observations for this livestock product in the region" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_region_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -keep if price_per_unit !=. -gen observation = 1 -bys livestock_code: egen obs_country = count(observation) -collapse (median) price_per_unit [aw=weight], by (livestock_code livestock_product obs_country) -ren price_per_unit price_median_country -lab var price_median_country "Median price per unit for this livestock product in the country" -lab var obs_country "Number of sales observations for this livestock product in the country" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_country_long.dta", replace - -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", clear -merge m:1 region zone woreda kebele livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_kebele_long.dta", nogen -merge m:1 region zone woreda livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_woreda_long.dta", nogen -merge m:1 region zone livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_zone_long.dta", nogen -merge m:1 region livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_region_long.dta", nogen -merge m:1 livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_prices_country_long.dta", nogen -replace price_per_unit = price_median_kebele if price_per_unit==. & obs_kebele >= 10 -replace price_per_unit = price_median_woreda if price_per_unit==. & obs_woreda >= 10 -replace price_per_unit = price_median_zone if price_per_unit==. & obs_zone >= 10 -replace price_per_unit = price_median_region if price_per_unit==. & obs_region >= 10 -replace price_per_unit = price_median_country if price_per_unit==. -lab var price_per_unit "Price per liter (milk) or per egg, imputed with local median prices if household did not sell" -gen value_produced = produced * price_per_unit -gen value_sold = sold_year * price_per_unit -recode earnings_milk_products (.=0) if livestock_product==2 | inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16) - -ren value_produced value_livestock_products -ren value_sold sales_livestock_products +******************************************************************************** +*SELF-EMPLOYMENT INCOME +******************************************************************************** +* BET 05.05.2021 +use "$Ethiopia_ESS_W4_temp_data/sect12b1_hh_W4.dta", clear +ren s12bq12 months_active +* four hh operated more than 12 months +replace months_active = 12 if months_active>12 // capping months operating at 12 +ren s12bq16 avg_monthly_sales +egen monthly_expenses = rowtotal(s12bq17a- s12bq17e) +recode avg_monthly_sales monthly_expenses (.=0) +gen monthly_profit = (avg_monthly_sales - monthly_expenses) +* many biz with negative profits, more than 25% of all biz +gen annual_selfemp_profit = monthly_profit * months_activ +recode annual_selfemp_profit (.=0) +collapse (sum) annual_selfemp_profit, by (household_id) +lab var annual_selfemp_profit "Estimated annual net profit from self-employment over previous 12 months" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_self_employment_income.dta", replace -collapse (sum) value_livestock_products earnings_milk_products sales_livestock_products, by(household_id livestock_code livestock_product) -recode value_livestock_products earnings_milk_products sales_livestock_products (0=.) if livestock_product==1 & (inlist(livestock_code,1,2,4,6) | inrange(livestock_code,9,16)) -recode value_livestock_products earnings_milk_products sales_livestock_products (0=.) if livestock_product==2 & (livestock_code!=11) -gen share_livestock_prod_sold = sales_livestock_products/value_livestock_products -*NOTE: there are quite a few that seem to have higher sales than production; going to cap these at one. N = 463 of 737 non-zero obs. -replace share_livestock_prod_sold = 1 if share_livestock_prod_sold>1 & share_livestock_prod_sold!=. -lab var share_livestock_prod_sold "Percent of production of livestock products that is sold" +*Female non-farm business owners // seems like the owner is identified but +use "$Ethiopia_ESS_W4_temp_data/sect12b1_hh_W4.dta", clear +ren s12bq12 months_active +* four hh operated more than 12 months +replace months_active = 12 if months_active>12 // capping months operating at 12 +ren s12bq16 avg_monthly_sales +egen monthly_expenses = rowtotal(s12bq17a- s12bq17e) +* 671 biz with negative profits +recode avg_monthly_sales monthly_expenses (.=0) +gen monthly_profit = (avg_monthly_sales - monthly_expenses) +gen annual_selfemp_profit = monthly_profit * months_activ +recode annual_selfemp_profit (.=0) +local busowners "s12bq03_1 s12bq03_2" +foreach v of local busowners { + preserve + keep household_id `v' + ren `v' bus_owner + drop if bus_owner==. | bus_owner==0 + tempfile `v' + save ``v'' + restore +} +use `s12bq03_1', clear +foreach v of local busowners { + if "`v'"!="`s12bq03_1'" { + append using ``v'' + } +} +duplicates drop +gen business_owner=1 if bus_owner!=. +ren bus_owner personid +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_business_owners_ind.dta", replace -lab var value_livestock_products "Value of milk/eggs produced" -lab var earnings_milk_products "Earnings from milk products sold (gross earnings only)" -lab var sales_livestock_products "Value of milk/eggs sold" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_long.dta", replace - -// SALES (live animals) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_w4.dta", clear -ren ls_code livestock_code -ren ls_s8_2q13 number_sold -ren ls_s8_2q14 income_live_sales -ren ls_s8_2q16 number_slaughtered -ren ls_s8_2q18 income_slaughtered -ren ls_s8_2q05 value_livestock_purchases -ren ls_s8_2q04 number_purchased -*We can't estimate the value of animals slaughtered because we don't know the number of slaughtered animals that were sold, just the number slaughtered and the value of sales of slaughtered animals. -*Although we might be able to estimate the value as though they were live sales. - -replace number_purchased = value_livestock_purchases if number_purchased > value_livestock_purchases -replace number_sold = income_live_sales if number_sold > income_live_sales -recode number_sold number_slaughtered value_livestock_purchases (.=0) -gen price_per_animal = income_live_sales / number_sold -recode price_per_animal (0=.) - -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" -drop if _merge==2 -drop _merge -collapse (sum) number_sold income_live_sales number_slaughtered income_slaughtered price_per_animal value_livestock_purchase, by(household_id weight region zone woreda kebele ea livestock_code) // collapsing income/costs across all land holders per household. -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", replace //note: long formatted live animals sales code is identical to orginal section. Copied here to retain code if wide format section is deleted eventually. HI 3.2.22 - -// IMPLICIT PRICES -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -keep if price_per_animal !=. -gen observation = 1 -bys region zone woreda kebele livestock_code: egen obs_kebele = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone woreda kebele livestock_code obs_kebele) -ren price_per_animal price_median_kebele -lab var price_median_kebele "Median price per unit for this livestock in the kebele" -lab var obs_kebele "Number of sales observations for this livestock in the kebele" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_kebele_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -keep if price_per_animal !=. -gen observation = 1 -bys region zone woreda livestock_code: egen obs_woreda = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone woreda livestock_code obs_woreda) -ren price_per_animal price_median_woreda -lab var price_median_woreda "Median price per unit for this livestock in the woreda" -lab var obs_woreda "Number of sales observations for this livestock in the woreda" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_woreda_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -keep if price_per_animal !=. -gen observation = 1 -bys region zone livestock_code: egen obs_zone = count(observation) -collapse (median) price_per_animal [aw=weight], by (region zone livestock_code obs_zone) -ren price_per_animal price_median_zone -lab var price_median_zone "Median price per unit for this livestock in the zone" -lab var obs_zone "Number of sales observations for this livestock in the zone" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_zone_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -keep if price_per_animal !=. -gen observation = 1 -bys region livestock_code: egen obs_region = count(observation) -collapse (median) price_per_animal [aw=weight], by (region livestock_code obs_region) -ren price_per_animal price_median_region -lab var price_median_region "Median price per unit for this livestock in the region" -lab var obs_region "Number of sales observations for this livestock in the region" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_region_long.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -keep if price_per_animal !=. -gen observation = 1 -bys livestock_code: egen obs_country = count(observation) -collapse (median) price_per_animal [aw=weight], by (livestock_code obs_country) -ren price_per_animal price_median_country -lab var price_median_country "Median price per unit for this livestock in the country" -lab var obs_country "Number of sales observations for this livestock in the country" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_country_long.dta", replace -*note: long formatted implicit prices code is identical to orginal section. Copied here to retain code if wide format section is deleted eventually. HI 3.2.22 - -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", clear -merge m:1 region zone woreda kebele livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_kebele_long.dta", nogen -merge m:1 region zone woreda livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_woreda_long.dta", nogen -merge m:1 region zone livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_zone_long.dta", nogen -merge m:1 region livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_region_long.dta", nogen -merge m:1 livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_country_long.dta", nogen -replace price_per_animal = price_median_kebele if price_per_animal==. & obs_kebele >= 10 -replace price_per_animal = price_median_woreda if price_per_animal==. & obs_woreda >= 10 -replace price_per_animal = price_median_zone if price_per_animal==. & obs_zone >= 10 -replace price_per_animal = price_median_region if price_per_animal==. & obs_region >= 10 -replace price_per_animal = price_median_country if price_per_animal==. -lab var price_per_animal "Price per animal sold, imputed with local median prices if household did not sell" - -gen value_lvstck_sold = price_per_animal * number_sold -gen value_slaughtered = price_per_animal * number_slaughtered -*replace value_slaughtered = income_slaughtered if (value_slaughtered < income_slaughtered) & number_slaughtered!=0 & income_slaughtered!=. /* Replace value of slaughtered animals with income from slaughtered-sales if the latter is larger */ -gen value_slaughtered_sold = income_slaughtered -gen value_livestock_sales = value_lvstck_sold + value_slaughtered_sold -collapse (sum) value_livestock_sales value_livestock_purchases value_slaughtered value_lvstck_sold, by(household_id livestock_code) -lab var value_livestock_sales "Value of livestock sold and slaughtered (with slaughtered livestock that weren't sold valued at local median prices for live animal sales)" -lab var value_livestock_purchases "Value of livestock purchases (seems to span only the agricultural season, not the year)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_sales_long", replace - -// TLU (Tropical Livestock Units) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_W4.dta", clear -gen tlu=0.5 if (ls_code==1|ls_code==2|ls_code==3|ls_code==4|ls_code==5|ls_code==6) -replace tlu=0.1 if (ls_code==7|ls_code==8) -replace tlu=0.7 if (ls_code==9) -replace tlu=0.01 if (ls_code==10|ls_code==11|ls_code==12) -replace tlu=0.5 if (ls_code==13) -replace tlu=0.6 if (ls_code==14) -replace tlu=0.3 if (ls_code==15) -lab var tlu "Tropical Livestock Unit coefficient" -ren tlu tlu_coefficient -*Owned -ren ls_s8_2q01 nb_ls_1yearago -ren ls_s8_2q02 nb_ls_born -ren ls_s8_2q04 nb_ls_purchased -ren ls_s8_2q07 nb_ls_gifts_received -ren ls_s8_2q09 nb_ls_gifts_given -ren ls_s8_2q11 nb_ls_lost -ren ls_s8_2q13 nb_ls_sold -ren ls_s8_2q16 nb_ls_slaughtered -ren ls_s8_2q14 value_soldsum -ren ls_s8_2q05 value_purchased - -replace nb_ls_purchased = value_purchased if nb_ls_purchased > value_purchased -replace nb_ls_purchased = 0 if nb_ls_purchased >= 1000 & value_purchased ==. -replace nb_ls_gifts_received = 0 if nb_ls_gifts_received >= 1000 /* Seem to have reported value of gifts, not number of animals */ -replace nb_ls_born = 0 if nb_ls_born >= 1000 -recode nb_ls_1yearago nb_ls_born nb_ls_purchased nb_ls_gifts_received nb_ls_gifts_given nb_ls_lost nb_ls_sold nb_ls_slaughtered (.=0) -replace nb_ls_slaughtered = 0 if nb_ls_slaughtered > (nb_ls_1yearago + nb_ls_born + nb_ls_purchased + nb_ls_gifts_received) -replace nb_ls_sold = 0 if nb_ls_sold > (nb_ls_1yearago + nb_ls_born + nb_ls_purchased + nb_ls_gifts_received) -gen nb_ls_today = nb_ls_1yearago + nb_ls_born + nb_ls_purchased + nb_ls_gifts_received - nb_ls_gifts_given - nb_ls_lost - nb_ls_sold - nb_ls_slaughtered -replace nb_ls_today = 0 if nb_ls_today < 0 - -gen tlu_1yearago = nb_ls_1yearago * tlu_coefficient -gen tlu_today = nb_ls_today * tlu_coefficient //in long format up to this point -collapse (sum) tlu_* nb_* , by (household_id ls_code) -lab var tlu_1yearago "Tropical Livestock Units as of 12 months ago" -lab var tlu_today "Tropical Livestock Units as of the time of survey" -lab var nb_ls_1yearago "Number of livestock owned as of 12 months ago" -lab var nb_ls_today "Number of livestock owned as of today" -drop tlu_coefficient nb_ls_born nb_ls_purchased nb_ls_gifts_received nb_ls_gifts_given nb_ls_lost nb_ls_sold nb_ls_slaughtered -rename ls_code livestock_code -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_Coefficients_long.dta", replace - -*TLU (Tropical Livestock Units) -use "$Ethiopia_ESS_W4_raw_data/sect8_2_ls_W4.dta", clear -gen tlu=0.5 if (ls_code==1|ls_code==2|ls_code==3|ls_code==4|ls_code==5|ls_code==6) -replace tlu=0.1 if (ls_code==7|ls_code==8) -replace tlu=0.7 if (ls_code==9) -replace tlu=0.01 if (ls_code==10|ls_code==11|ls_code==12) -replace tlu=0.5 if (ls_code==13) -replace tlu=0.6 if (ls_code==14) -replace tlu=0.3 if (ls_code==15) -lab var tlu "Tropical Livestock Unit coefficient" -ren ls_code livestock_code -ren tlu tlu_coefficient -ren ls_s8_2q01 number_1yearago -ren ls_s8_2q02 number_born -ren ls_s8_2q04 number_purchased -ren ls_s8_2q07 number_gifts_received -ren ls_s8_2q09 number_gifts_given -ren ls_s8_2q11 animals_lost12months -ren ls_s8_2q13 number_sold -ren ls_s8_2q16 number_slaughtered -ren ls_s8_2q14 value_sold -* replace number_sold = value_sold if number_sold > value_sold /* columns seem to be switched */ -ren ls_s8_2q05 value_purchased -replace number_purchased = value_purchased if number_purchased > value_purchased -replace number_purchased = 0 if number_purchased >= 1000 & value_purchased ==. -replace number_gifts_received = 0 if number_gifts_received >= 1000 /* Seem to have reported value of gifts, not number of animals */ -replace number_born = 0 if number_born >= 1000 -recode number_1yearago number_born number_purchased number_gifts_received number_gifts_given animals_lost12months number_sold number_slaughtered (.=0) -replace number_slaughtered = 0 if number_slaughtered > (number_1yearago + number_born + number_purchased + number_gifts_received) -replace number_sold = 0 if number_sold > (number_1yearago + number_born + number_purchased + number_gifts_received) -gen number_today = number_1yearago + number_born + number_purchased + number_gifts_received - number_gifts_given - animals_lost12months - number_sold - number_slaughtered -replace number_today = 0 if number_today < 0 -gen tlu_1yearago = number_1yearago * tlu_coefficient - -*Livestock mortality rate -ren livestock_code ls_code -merge m:1 ls_code household_id holder_id using "$Ethiopia_ESS_W4_raw_data/sect8_1_ls_W4.dta", nogen -ren ls_code livestock_code -replace number_today = ls_s8_1q01 -gen tlu_today = number_today * tlu_coefficient -egen mean_12months = rowmean(number_today number_1yearago) -ren ls_s8_1q03 number_today_exotic -gen share_imp_herd_cows = number_today_exotic/number_today if livestock_code==3 // should this be all large ruminants or just cows? -gen species = (inlist(livestock_code,1,2,3,4,5,6)) + 2*(inlist(livestock_code,7,8)) + 3*(inlist(livestock_code,9)) + 4*(inlist(livestock_code,10,11,12)) + 5*(inlist(livestock_code,13,14,15)) -recode species (0=.) -la def species 1 "Large ruminants (cows)" 2 "Small ruminants (sheep, goats)" 3 "Camels" 4 "Equine (horses, donkies, mules)" 5 "Poultry" -la val species species - -preserve -*Now to household level -*First, generating these values by livestock code -collapse (firstnm) share_imp_herd_cows (sum) number_today number_1yearago animals_lost12months number_today_exotic lvstck_holding=number_today, by(household_id livestock_code) -egen mean_12months = rowmean(number_today number_1yearago) -gen any_imp_herd = number_today_exotic!=0 if number_today!=. & number_today!=0 -drop number_today_exotic number_today - -la var lvstck_holding "Total number of livestock holdings (# of animals)" -la var any_imp_herd "At least one improved animal in herd" -la var share_imp_herd_cows "Share of improved animals in total herd - Cows only" -lab var animals_lost12months "Total number of livestock lost to disease" -lab var mean_12months "Average number of livestock today and 1 year ago" - -*Now dropping these missing variables, which we only used to construct the labels above -drop number_1yearago -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_herd_characteristics_long.dta", replace -restore - -*Bee colonies not captured in TLU. -gen price_per_animal = value_sold / number_sold -recode price_per_animal (0=.) - -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) -merge m:1 region zone woreda kebele livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_kebele_long.dta", nogen -merge m:1 region zone woreda livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_woreda_long.dta", nogen -merge m:1 region zone livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_zone_long.dta", nogen -merge m:1 region livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_region_long.dta", nogen -merge m:1 livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_prices_country_long.dta", nogen -replace price_per_animal = price_median_kebele if price_per_animal==. & obs_kebele >= 10 -replace price_per_animal = price_median_woreda if price_per_animal==. & obs_woreda >= 10 -replace price_per_animal = price_median_zone if price_per_animal==. & obs_zone >= 10 -replace price_per_animal = price_median_region if price_per_animal==. & obs_region >= 10 -replace price_per_animal = price_median_country if price_per_animal==. -lab var price_per_animal "Price per animal sold, imputed with local median prices if household did not sell" -gen value_1yearago = number_1yearago * price_per_animal -gen value_today = number_today * price_per_animal -collapse (sum) tlu_1yearago tlu_today value_1yearago value_today, by(household_id livestock_code) -lab var tlu_1yearago "Tropical Livestock Units as of 12 months ago" -lab var tlu_today "Tropical Livestock Units as of the time of survey" -lab var value_1yearago "Value of livestock holdings from one year ago" -lab var value_today "Value of livestock holdings today" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_long.dta", replace - -// ALL LIVESTOCK -*Assembling individual costs into single file with all costs/associated variables by hhid, livestock_code. -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", clear -merge 1:m household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_lrum_expenses_long", nogen // ISSUE WITH MISSING LIVESTOCK CODES. File merged in at Line 1453 has data at ls_type level, not at species level (livestock_code). 728 obs not matched by HHID and lack weight/other geographic columns, but have livestock_code and household_id. 104 obs without household/geographic data or livestock_code (just have household_id and cost_lrum) - may need to drop since other sections won't be able to be matched to these. -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_expenses_long", nogen // has some missing . livestock code obs -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_sales_long", nogen -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_sales_long", nogen -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_Coefficients_long.dta", nogen -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_herd_characteristics_long.dta", nogen -merge 1:m household_id livestock_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_long.dta", nogen - -*Filling in missing geographic/weight fields -foreach var in weight region zone woreda city subcity household rural { - bysort household_id (`var'): replace `var' = `var'[1] if `var'==. -} -bysort household_id: replace kebele = kebele[1] if kebele=="" -bysort household_id: replace ea = ea[1] if ea=="" -gsort household_id livestock_code - -*Tried building loop that operates over all geo variables...doesn't work for string variables kebele and ea. -/* -foreach var in weight region zone woreda city subcity kebele ea household rural { - local vartype: type `var' - if substr("`vartype'",1,3)=="str" { - bysort household_id (`var'): replace `var' = `var'[1] if `var'=="" - } - else { - bysort household_id (`var'): replace `var' = `var'[1] if `var'==. - } -} -*/ - -*Prep dataset for merging livestock product data -gen livestock_product1 = 1 -gen livestock_product2 = 2 -reshape long livestock_product, i(household_id livestock_code) j(lsprod_id) -drop lsprod_id -la def livestock_product 1 "Milk" 2 "Eggs" -la val livestock_product livestock_product - -*Merge livestock product data -merge m:1 household_id livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_livestock_products_long", nogen //livestock_code, livestock_product (2 rows per hhid/livestock_code) -merge m:1 household_id livestock_code livestock_product using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products_long", nogen //livestock_code, livestock_product (2 rows per hhid/livestock_code) -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_livestock.dta", replace - - -******************************************************************************** -*SELF-EMPLOYMENT INCOME -******************************************************************************** -* BET 05.05.2021 -use "$Ethiopia_ESS_W4_raw_data/Household/sect12b1_hh_W4.dta", clear -ren s12bq12 months_active -* four hh operated more than 12 months -replace months_active = 12 if months_active>12 // capping months operating at 12 -ren s12bq16 avg_monthly_sales -egen monthly_expenses = rowtotal(s12bq17a- s12bq17e) -recode avg_monthly_sales monthly_expenses (.=0) -gen monthly_profit = (avg_monthly_sales - monthly_expenses) -* many biz with negative profits, more than 25% of all biz -gen annual_selfemp_profit = monthly_profit * months_activ -recode annual_selfemp_profit (.=0) -collapse (sum) annual_selfemp_profit, by (household_id) -lab var annual_selfemp_profit "Estimated annual net profit from self-employment over previous 12 months" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_self_employment_income.dta", replace - -*Female non-farm business owners // seems like the owner is identified but -use "$Ethiopia_ESS_W4_raw_data/Household/sect12b1_hh_W4.dta", clear -ren s12bq12 months_active -* four hh operated more than 12 months -replace months_active = 12 if months_active>12 // capping months operating at 12 -ren s12bq16 avg_monthly_sales -egen monthly_expenses = rowtotal(s12bq17a- s12bq17e) -* 671 biz with negative profits -recode avg_monthly_sales monthly_expenses (.=0) -gen monthly_profit = (avg_monthly_sales - monthly_expenses) -gen annual_selfemp_profit = monthly_profit * months_activ -recode annual_selfemp_profit (.=0) -local busowners "s12bq03_1 s12bq03_2" -foreach v of local busowners { - preserve - keep household_id `v' - ren `v' bus_owner - drop if bus_owner==. | bus_owner==0 - tempfile `v' - save ``v'' - restore -} -use `s12bq03_1', clear -foreach v of local busowners { - if "`v'"!="`s12bq03_1'" { - append using ``v'' - } -} -duplicates drop -gen business_owner=1 if bus_owner!=. -ren bus_owner personid -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_business_owners_ind.dta", replace - - -******************************************************************************** -*WAGE INCOME -******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Household/sect4_hh_W4.dta", clear -ren s4q34b occupation_code -ren s4q34d industry_code -gen mainwage_yesno=0 -replace mainwage_yesno=1 if s4q33==1 | s4q33b==1 +******************************************************************************** +*WAGE INCOME +******************************************************************************** +use "$Ethiopia_ESS_W4_temp_data/sect4_hh_W4.dta", clear +ren s4q34b occupation_code +ren s4q34d industry_code +gen mainwage_yesno=0 +replace mainwage_yesno=1 if s4q33==1 | s4q33b==1 // Note: questionnaire and data conflict on questions 38 -44 BET 05.06.2021 ren s4q37 mainwage_number_months @@ -2023,7 +3016,7 @@ gen annual_salary = mainwage_annual_salary + income_psnp *Individual agwage earners preserve ren individual_id personid -merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", nogen +merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_person_ids.dta", nogen //DYA; 7.3.2023: Here we are using Ethiopia_ESS_W4_person_ids which include the gender of everyone gen wage_worker = (annual_salary!=0 & annual_salary!=.) save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wage_worker.dta", replace restore @@ -2033,7 +3026,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wage_income.dta", replace *Occupation = Ag or Industry = Ag or Fisheries. *Agwage -use "$Ethiopia_ESS_W4_raw_data/Household/sect4_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_hh_W4.dta", clear ren s4q34b occupation_code ren s4q34d industry_code gen mainwage_yesno=0 @@ -2075,7 +3068,7 @@ gen annual_salary_agwage = mainwage_annual_salary *Individual agwage earners preserve ren individual_id personid -merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", nogen +merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_person_ids.dta", nogen //DYA; 7.3.2023: Here we are using Ethiopia_ESS_W4_person_ids which include the gender of everyone gen agworker = (annual_salary_agwage!=0 & annual_salary_agwage!=.) save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_agworker.dta", replace restore @@ -2088,7 +3081,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_agwage_income.dta", replac ******************************************************************************** *OTHER INCOME ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Household/sect13_hh_W4_v2.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect13_hh_W4_v2.dta", clear ren s13q02 amount_received gen transfer_income = amount_received if source_cd==101|source_cd==102|source_cd==103 /* cash, food, other in-kind transfers */ gen investment_income = amount_received if source_cd==104 @@ -2106,7 +3099,7 @@ lab var rental_income "Estimated income from rentals of buildings, tools, land, lab var inheritance_income "Estimated income from cinheritance over previous 12 months" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_other_income.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Household/sect14_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect14_hh_W4.dta", clear * BET 05.13.2021 W4 makes the distinction between cash, inkind, or food transfers rename assistance_cd assistance_code rename s14q03 cash_received @@ -2123,7 +3116,7 @@ lab var psnp_income "Estimated income from a PSNP over previous 12 months" lab var assistance_income "Estimated income from a food aid, food-for-work, etc. over previous 12 months" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_assistance_income.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", clear ren s2q15a land_rental_income_cash ren s2q15b land_rental_income_inkind ren s2q15c land_rental_income_share @@ -2138,7 +3131,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_rental_income.dta", r ******************************************************************************** *OFF-FARM HOURS ******************************************************************************** -use "${Ethiopia_ESS_W4_raw_data}/Household/sect4_hh_W4.dta", clear +use "${Ethiopia_ESS_W4_temp_data}/sect4_hh_W4.dta", clear ren hh_s4q10_b occupation_code ren hh_s4q11_b industry_code gen primary_hours = hh_s4q15 if occupation_code!=6 | industry_code!=1 | industry_code!=2 @@ -2159,7 +3152,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_off_farm_hours.dta", repla ******************************************************************************** *OFF-FARM HOURS ******************************************************************************** -use "${Ethiopia_ESS_W4_raw_data}/Household/sect4_hh_W4.dta", clear +use "${Ethiopia_ESS_W4_temp_data}/sect4_hh_W4.dta", clear // BET 05.14.2021 questionnaire and dta files differ in question numbers / text // W4 questionnaire askes about wage hours in two places Q13 and Q39, using question attached to main job over last 12 months gen hrs_main_wage_off_farm=s4q39 if (s4q34d>2 & s4q34d!=.) // s4q34d 1 to 2 is agriculture (exclude mining) //DYA.10.26.2020 I think this is limited to only @@ -2210,12 +3203,12 @@ la var nworker_other_all "Number of HH members with positve hours - other activi save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_off_farm_hours.dta", replace - +/* ALT: Old ******************************************************************************** *FARM LABOR ******************************************************************************** *Farm labor -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear ren s3q30a number_men ren s3q30b number_days_men ren s3q30d number_women @@ -2260,7 +3253,7 @@ lab var days_hired_postplant "Workdays for hired labor (crops), as captured in p lab var days_otherlabor_postplant "Workdays for other labor (crops), as captured in post-planting survey" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmlabor_postplanting.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect10_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect10_ph_W4.dta", clear ren s10q01a number_men ren s10q01b number_days_men ren s10q01d number_women @@ -2318,198 +3311,210 @@ lab var labor_family "Total labor days (family) allocated to the farm in the pas lab var labor_other "Total labor days (other/gang/communal) allocated to the farm in the past year" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmlabor_all.dta", replace +*/ ******************************************************************************** -*FARM SIZE +*FARM LABOR ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_W4.dta", clear -*All parcels here (which are subdivided into fields) were cultivated, whether in the belg or meher season. -gen cultivated=1 - -*Including area of permanent crops +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_labor_long.dta", clear +// drop if strmatch(gender,"all") *Not relevant to ETH +rename labor_type type +replace type="family" if type=="nonhired" +ren days labor_ +collapse (sum) labor_, by(hhid type gender) +reshape wide labor_, i(hhid gender) j(type) string +drop if strmatch(gender,"") +ren labor* labor*_ +reshape wide labor*, i(hhid) j(gender) string +egen labor_total=rowtotal(labor*) +egen labor_hired = rowtotal(labor_hired*) +egen labor_family = rowtotal(labor_family*) +lab var labor_total "Total labor days (family, hired, or other) allocated to the farm in the past year" +lab var labor_hired "Total labor days (hired) allocated to the farm in the past year" +lab var labor_family "Total labor days (family) allocated to the farm in the past year" +lab var labor_hired_male "Workdays for male hired labor allocated to the farm in the past year" +lab var labor_hired_female "Workdays for female hired labor allocated to the farm in the past year" +keep hhid labor_total labor_hired labor_family labor_hired_male labor_hired_female +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_family_hired_labor.dta", replace + +/* ALT: Old +******************************************************************************** +*FARM SIZE +******************************************************************************** +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear +ren household_id hhid +*All parcels here (which are subdivided into fields) were cultivated, whether in the belg or meher season. +gen cultivated=1 + +*Including area of permanent crops preserve -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear -gen cultivated = 1 if (s4q19!=0 & s4q19!=.) // not including any harvest because not separated out for tree crops in ETH (KEF:???) -collapse (max) cultivated, by (household_id parcel_id field_id) +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear +ren household_id hhid +gen cultivated = 1 if (s4q19!=0 & s4q19!=.) // MGM 5.20.2024: Why do we use this question for cultivated and not 'What is the number of Fruit Bearing Trees' on...?' +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) tempfile tree save `tree', replace restore + append using `tree' -collapse (max) cultivated, by (household_id parcel_id field_id) +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) lab var cultivated "1= Field was cultivated in this data set" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_cultivated.dta", replace +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta", replace + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear +merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta" +keep if cultivated==1 +collapse (sum) field_size, by (hhid holder_id parcel_id field_id) +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", replace +collapse (sum) field_size, by (hhid holder_id parcel_id) +ren field_size parcel_size +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcel_sizes.dta", replace + +collapse (sum) parcel_size, by (hhid) +ren parcel_size farm_area +lab var farm_area "Land size (denominator for land productivitiy), in hectares" /* Uses measures */ +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -ren s3q02a area -ren s3q02b local_unit -ren s3q08 area_sqmeters_gps -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -replace area_sqmeters_gps=. if area_sqmeters_gps==0 -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) -gen sqmeters_per_unit = area_sqmeters_gps/area -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region zone local_unit) -ren sqmeters_per_unit sqmeters_per_unit_zone -ren observations obs_zone -lab var sqmeters_per_unit_zone "Square meters per local unit (median value for this region and zone)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -ren s3q02a area -ren s3q02b local_unit -ren s3q08 area_sqmeters_gps -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" -drop if _merge==2 -drop _merge -gen sqmeters_per_unit = area_sqmeters_gps/area -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (region local_unit) -ren sqmeters_per_unit sqmeters_per_unit_region -ren observations obs_region -lab var sqmeters_per_unit_region "Square meters per local unit (median value for this region)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -ren s3q02a area -ren s3q02b local_unit -ren s3q08 area_sqmeters_gps -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -keep household_id parcel_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta" -drop if _merge==2 -drop _merge -gen sqmeters_per_unit = area_sqmeters_gps/area -gen observations = 1 -collapse (median) sqmeters_per_unit (count) observations [aw=weight], by (local_unit) -ren sqmeters_per_unit sqmeters_per_unit_country -ren observations obs_country -lab var sqmeters_per_unit_country "Square meters per local unit (median value for the country)" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", replace +*All Agricultural Land +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear +ren household_id hhid +gen agland = (s3q03==1 | s3q03==2 | s3q03==3 | s3q03==5) // Cultivated, prepared for Belg season, pasture, or fallow. Excludes forest, homestead, and "other" (which seems to include rented-out) +*Including area of permanent crops +preserve +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear +ren household_id hhid +gen cultivated = 1 if (s4q19!=0 & s4q19!=.) //not including any harvest because not separated out for tree crops in ETH +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) +tempfile tree +save `tree', replace +restore +append using `tree' +merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta", nogen keep(1 3) +replace agland=1 if cultivated==1 +keep if agland==1 +collapse (max) agland, by(hhid holder_id parcel_id field_id) +lab var agland "1= Plot was used for cultivated, pasture, or fallow" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_agland.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -ren s3q02a area -ren s3q02b local_unit -ren s3q08 area_sqmeters_gps -replace area_sqmeters_gps=. if area_sqmeters_gps<0 -replace area_sqmeters_gps=. if area_sqmeters_gps==0 -keep household_id parcel_id holder_id field_id area local_unit area_sqmeters_gps -merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen keep(1 3) -//DYA: 8.10.2021 -//KEF: problem here that local area unit uses bytes instead of strings for zones and woredas. Created string version in the created data folder. +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", clear +merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_agland.dta", keep(1 3) nogen //MGM 5.20.2024 - should this be field_agland or fields_agland +keep if agland==1 +collapse (sum) field_size, by (hhid) +ren field_size farm_size_agland +lab var farm_size_agland "Land size in hectares, including all plots cultivated, fallow, or pastureland" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmsize_all_agland.dta", replace + +*Rented In/Borrow/Other not own +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", clear +collapse (sum) field_size, by(hhid) +ren field_size land_size_total +lab var land_size_total "Total land size in hectares, including rented in and rented out plots" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size_all.dta", replace +*/ + + +******************************************************************************** +*FARM SIZE * +******************************************************************************** +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear +ren household_id hhid +*All parcels here (which are subdivided into fields) were cultivated, whether in the belg or meher season. +gen cultivated=1 + +*Including area of permanent crops preserve -use "$Ethiopia_ESS_W4_raw_data/Land Area Conversion Factor/ET_local_area_unit_conversion.dta", clear -destring region zone woreda, replace -tempfile ET_local_area_unit_conversion -save `ET_local_area_unit_conversion' +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear +ren household_id hhid +gen cultivated = 1 if (s4q19!=0 & s4q19!=.) // MGM 5.20.2024: Why do we use this question for cultivated and not 'What is the number of Fruit Bearing Trees' on...?' +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) +tempfile tree +save `tree', replace restore -merge m:1 region zone woreda local_unit using `ET_local_area_unit_conversion', nogen keep(1 3) -gen area_est_hectares = area if local_unit==1 -replace area_est_hectares = (area/10000) if local_unit==2 -replace area_est_hectares = (area*conversion/10000) if (local_unit!=1 & local_unit!=2 & local_unit!=11) -merge m:1 region zone local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_zone.dta", nogen -replace area_est_hectares = (area*(sqmeters_per_unit_zone/10000)) if local_unit!=11 & area_est_hectares==. & obs_zone>=10 -merge m:1 region local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_region.dta", nogen -replace area_est_hectares = (area*(sqmeters_per_unit_region/10000)) if local_unit!=11 & area_est_hectares==. & obs_region>=10 -merge m:1 local_unit using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_lookup_country.dta", nogen -replace area_est_hectares = (area*(sqmeters_per_unit_country/10000)) if local_unit!=11 & area_est_hectares==. -gen area_meas_hectares = (area_sqmeters_gps/10000) -replace area_meas_hectares = area_est_hectares if area_meas_hectares==. -count if area!=. & area_meas_hectares==. -replace area_meas_hectares = 0 if area_meas_hectares == . -lab var area_meas_hectares "Area measured in hectares, with missing obs imputed using local median per-unit values" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plot_sizes.dta", replace -merge m:1 household_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_cultivated.dta" -keep if cultivated==1 -collapse (sum) area_meas_hectares, by (household_id) -ren area_meas_hectares farm_area + +append using `tree' +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) +lab var cultivated "1= Field was cultivated in this data set" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta", replace + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear +merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta" +keep if cultivated==1 +collapse (sum) field_size, by (hhid holder_id parcel_id field_id) +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", replace +collapse (sum) field_size, by (hhid holder_id parcel_id) +ren field_size parcel_size +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcel_sizes.dta", replace + +collapse (sum) parcel_size, by (hhid) +ren parcel_size farm_area lab var farm_area "Land size (denominator for land productivitiy), in hectares" /* Uses measures */ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size.dta", replace - *All Agricultural Land -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -gen agland = (s3q03==1 | s3q03==2 | s3q03==3 | s3q03==5) // Cultivated, prepared for Belg season, pasture, or fallow. Excludes forest and "other" (which seems to include rented-out) - +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear +ren household_id hhid +gen agland = (s3q03==1 | s3q03==2 | s3q03==3 | s3q03==5) // Cultivated, prepared for Belg season, pasture, or fallow. Excludes forest, homestead, and "other" (which seems to include rented-out) *Including area of permanent crops preserve -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear +ren household_id hhid gen cultivated = 1 if (s4q19!=0 & s4q19!=.) //not including any harvest because not separated out for tree crops in ETH -collapse (max) cultivated, by (household_id parcel_id field_id) +collapse (max) cultivated, by (hhid holder_id parcel_id field_id) tempfile tree save `tree', replace restore append using `tree' -merge m:1 household_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_cultivated.dta", nogen keep(1 3) +merge m:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_cultivated.dta", nogen keep(1 3) replace agland=1 if cultivated==1 keep if agland==1 -keep household_id parcel_id field_id holder_id agland +collapse (max) agland, by(hhid holder_id parcel_id field_id) lab var agland "1= Plot was used for cultivated, pasture, or fallow" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_agland.dta", replace +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fields_agland.dta", replace -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plot_sizes.dta", clear -merge 1:1 household_id parcel_id holder_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_agland.dta" -drop if _merge==1 -collapse (sum) area_meas_hectares, by (household_id) -ren area_meas_hectares farm_size_agland +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", clear +merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_agland.dta", keep(1 3) nogen //MGM 5.20.2024 - should this be field_agland or fields_agland +keep if agland==1 +collapse (sum) field_size, by (hhid) +ren field_size farm_size_agland lab var farm_size_agland "Land size in hectares, including all plots cultivated, fallow, or pastureland" -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmsize_all_agland.dta", replace - -/*KEF: Not sure why the following is excluded. -Rented In/Borrow/Other not own -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plot_sizes.dta", clear -collapse (sum) area_meas_hectares, by( holder_id household_id parcel_id parcel_id) -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcel_area.dta",replace -*/ - -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear -gen rented_in = (s2q05==3 | s2q05==6) -gen plot_not_owned = (s2q05==3 | s2q05==4 | s2q05==5 | s2q05==6 ) -gen plot_owned = (s2q05==1 | s2q05==2 | s2q05==7 | s2q05==8) //KEF: should we include 8 (Other) here? It doesn't necessarily mean owned. -gen rented_out = (s2q13==1 | s2q13==2 | s2q13==3) //KEF: In W4 they expanded the responses here from Yes/No to include 1 (Yes, all in all rent) 2 (Yes, all in all share) and 3 (Yes, all free). -*keep if pp_s2q01b==1 //KEF: got rid of this "Is this parcel still owned or rented in by the holder" since this is the first survey for this sample. -collapse (max) rented_in rented_out plot_not_owned plot_owned, by (holder_id household_id parcel_id) -preserve -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_agland.dta", clear -collapse (max) agland, by (holder_id household_id parcel_id) -tempfile agland -save `agland', replace -restore -merge 1:1 holder_id household_id parcel_id using `agland', nogen -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plot_ownership.dta", replace -merge 1:1 holder_id household_id parcel_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcel_area.dta", nogen keep (3) //KEF: Somewhere in these two lines, rented_out suddenly loses all of its 516 affirmative values. Which results in an error in line 1905. In line 1892, rented_out still has values. -gen not_own_area = area_meas_hectares if plot_not_owned==1 -gen rent_out_area = area_meas_hectares if rented_out==1 -collapse (sum) not_own_area rent_out_area area_meas_hectares (max) rented_in plot_not_owned plot_owned rented_out agland, by (household_id) -gen prop_area_not_own = not_own_area/area_meas_hectares -gen prop_area_rent = rent_out_area/area_meas_hectares -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_plot_ownership.dta", replace - -merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", keep (3) -gen only_unown = (plot_not_owned==1 & plot_owned==0) -tabstat only_unown [aw=weight] -*tabstat prop_area_not_own [aw=weight] if plot_not_owned==1 //KEF: Error here, no observations. -gen only_rent_out = (rented_out==1 & (agland==0 |plot_not_owned==1) ) -tabstat only_rent_out rented_out [aw=weight] -*tabstat prop_area_rent [aw=weight] if rented_out==1 -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmsize_all_agland.dta", replace +*Rented In/Borrow/Other not own +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_sizes.dta", clear +collapse (sum) field_size, by(hhid) +ren field_size land_size_total +lab var land_size_total "Total land size in hectares, including rented in and rented out plots" +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size_total.dta", replace ******************************************************************************** -*LAND SIZE +*LAND SIZE * ******************************************************************************** -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plot_sizes.dta", clear -collapse (sum) area_meas_hectares, by (household_id) +use "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", clear +ren household_id hhid +gen rented_in = (s2q05==3 | s2q05==6) +gen plot_not_owned = ( s2q05==3 | s2q05==4 | s2q05==5 | s2q05==6 ) +gen plot_owned = (s2q05==1 | s2q05==2 | s2q05==7 | s2q05==8) +gen rented_out= (s2q13<4) // MGM 5.20.2024 - questionaire changed a bit from W3 to W5 +drop if rented_out==1 +gen parcel_held = 1 +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_held.dta", replace + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear +collapse (sum) area_meas_hectares, by (hhid holder_id parcel_id) +merge 1:1 hhid holder_id parcel_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_parcels_held.dta", nogen keep(1 3) +keep if parcel_held==1 +collapse (sum) area_meas_hectares, by(hhid) ren area_meas_hectares land_size -lab var land_size "Land size in hectares, including all plots listed by the household (and not rented out)" /* Uses measures */ +lab var land_size "Land size in hectares, including all plots listed by the household (and not rented out)" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size_all.dta", replace + ******************************************************************************** * VACCINE USAGE * ******************************************************************************** * UPDATED BY BT 05.14.2021 -use "$Ethiopia_ESS_W4_raw_data/sect8_3_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_3_ls_W4.dta", clear gen vac_animal=. replace vac_animal=1 if ls_s8_3q18==1 replace vac_animal=0 if ls_s8_3q18==2 @@ -2541,7 +3546,7 @@ foreach i in vac_animal { save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_vaccine.dta", replace *Vaccine use livestock keeper (holder) -use "$Ethiopia_ESS_W4_raw_data/sect8_3_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_3_ls_W4.dta", clear ren saq09 farmerid gen all_vac_animal=. @@ -2551,8 +3556,8 @@ replace all_vac_animal=. if ls_s8_3q18==. collapse (max) all_vac_animal , by(household_id farmerid) gen personid=farmerid drop if personid==. -merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", gen(f_merge) keep(1 3) -keep household_id personid holder_id all_vac female +merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_person_ids.dta", gen(f_merge) keep(1 3) //DYA; 7.3.2023: Here we are using Ethiopia_ESS_W4_person_ids which include the gender of everyone +keep household_id personid all_vac female gen female_vac_animal=all_vac_animal if female==1 gen male_vac_animal=all_vac_animal if female==0 lab var all_vac_animal "1 = Individual farmer (livestock keeper) uses vaccines" @@ -2564,6 +3569,100 @@ lab var livestock_keeper "1=Indvidual is listed as a livestock keeper (at least save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_vaccine.dta", replace +******************************************************************************** +* PLOT MANAGERS * +******************************************************************************** +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear +ren household_id hhid +ren s4q01b crop_code +gen use_imprv_seed = (s4q11 == 2) +collapse (max) use_imprv_seed, by(hhid holder_id parcel_id field_id crop_code) +tempfile imprv_seed +save `imprv_seed' + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_area.dta", clear +ren s3q13 pid1 +ren s3q15_1 pid2 +ren s3q15_2 pid3 +keep hhid holder_id parcel_id field_id pid* +reshape long pid, i(hhid holder_id parcel_id field_id) j(pidno) +drop pidno +drop if pid==. +ren pid personid +//ALT QUICK FIX +ren hhid household_id +merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", nogen keep(1 3) // MGM 5.18.2024: all matched +ren household_id hhid +tempfile personids +save `personids' + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_quantities.dta", clear +rename use_inorg use_inorg_fert +rename use_org use_org_fert +collapse (max) use_org_fert use_inorg_fert use_fung use_herb use_pest, by(hhid holder_id parcel_id field_id) +merge 1:m hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", nogen keep(1 3) keepusing(crop_code_master) //MGM 5.18.2024: 26 not matched, 14,184 observations matched +ren crop_code_master crop_code +collapse (max) use*, by(hhid holder_id parcel_id field_id crop_code) +merge 1:1 hhid holder_id parcel_id field_id crop_code using `imprv_seed', nogen +recode use* (.=0) +preserve +keep hhid holder_id parcel_id field_id crop_code use_imprv_seed +ren use_imprv_seed imprv_seed_ +gen hybrid_seed_ = . +collapse (max) imprv_seed_ hybrid_seed_, by(hhid crop_code) +merge m:1 crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropname_table.dta", nogen keep(3) +drop crop_code +reshape wide imprv_seed_ hybrid_seed_, i(hhid) j(crop_name) string +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_imprvseed_crop.dta", replace +restore + + +merge m:m hhid holder_id parcel_id field_id using `personids', keep(1 3) +preserve +ren use_imprv_seed all_imprv_seed_ +gen all_hybrid_seed_ =. +collapse (max) all*, by(hhid personid female crop_code) +merge m:1 crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropname_table.dta", nogen keep(3) +drop crop_code +gen farmer_=1 +/* +bysort hhid holder_id parcel_id field_id individual_id2 female crop_name: gen dup = cond(_N==1,0,_n) +tab dup +*/ +reshape wide all_imprv_seed_ all_hybrid_seed_ farmer_, i(hhid personid female) j(crop_name) string +recode farmer_* (.=0) +ren farmer_* *_farmer +bysort hhid personid: gen dup=cond(_N==1,0,_n) +tab dup +drop dup +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_improvedseed_use.dta", replace +restore + +collapse (max) use_*, by(hhid personid female) +gen all_imprv_seed_use = use_imprv_seed //Legacy + preserve + collapse (max) use_inorg_fert use_imprv_seed use_org_fert use_pest use_herb use_fung, by (hhid) + la var use_inorg_fert "1= Household uses inorganic fertilizer" + la var use_pest "1 = household uses pesticide" + la var use_herb "1 = household uses herbicide" + la var use_fung "1 = household uses fungicide" + la var use_org_fert "1= household uses organic fertilizer" + la var use_imprv_seed "1=household uses improved or hybrid seeds for at least one crop" + gen use_hybrid_seed = . + la var use_hybrid_seed "1=household uses hybrid seeds (not in this wave - see imprv_seed)" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_use.dta", replace +restore + +preserve + ren use_inorg_fert all_use_inorg_fert + lab var all_use_inorg_fert "1 = Individual farmer (plot manager) uses inorganic fertilizer" + gen farm_manager=1 if !missing(personid) + recode farm_manager (.=0) + lab var farm_manager "1=Individual is listed as a manager for at least one plot" + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_fert_use.dta", replace //This is currently used for AgQuery. +restore + + ******************************************************************************** *ANIMAL HEALTH - DISEASES ******************************************************************************** @@ -2575,7 +3674,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_vaccine.dta", repla *LIVESTOCK WATER, FEEDING, AND HOUSING ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/sect8_3_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_3_ls_W4.dta", clear // data labels do not indicate which question corresponds to rainy vs dry season. assuming that _1 "Feed 1" corresponds to the dry and _2 "Feed 2" corresponds to the rainy, based on questionnaire order BET 05.14.2021 gen feed_grazing_dry = (ls_s8_3q12_1==1 | ls_s8_3q12_1==2) gen feed_grazing_rainy = (ls_s8_3q12_2==1 | ls_s8_3q12_2==2) @@ -2626,11 +3725,11 @@ foreach i in feed_grazing water_source_nat water_source_const water_source_cover } save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_feed_water_house.dta", replace - +/* ALT: Old ******************************************************************************** * INORGANIC FERTILIZER USE * ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear gen use_inorg_fert=0 replace use_inorg_fert=1 if s3q21==1 | s3q22==1 | s3q23==1 | s3q24==1 replace use_inorg_fert=0 if s3q21==2 & s3q22==2 & s3q23==2 & s3q24==2 @@ -2640,7 +3739,7 @@ lab var use_inorg_fert "1= Household uses inorganic fertilizer" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fert_use.dta", replace *Fertilizer use by farmers (a farmer is an individual listed as plot manager) -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear gen all_use_inorg_fert=0 replace all_use_inorg_fert=1 if s3q21==1 | s3q22==1 | s3q23==1 | s3q24==1 replace all_use_inorg_fert=0 if s3q21==2 & s3q22==2 & s3q23==2 & s3q24==2 @@ -2656,16 +3755,16 @@ gen male_use_inorg_fert=all_use_inorg_fert if female==0 lab var all_use_inorg_fert "1 = Individual farmer (plot manager) uses inorganic fertilizer" lab var male_use_inorg_fert "1 = Individual male farmers (plot manager) uses inorganic fertilizer" lab var female_use_inorg_fert "1 = Individual female farmers (plot manager) uses inorganic fertilizer" -gen farm_manager=1 if personid!=. -recode farm_manager (.=0) -lab var farm_manager "1=Indvidual is listed as a manager for at least one plot" +*gen farm_manager=1 if personid!=. +*recode farm_manager (.=0) +*lab var farm_manager "1=Indvidual is listed as a manager for at least one plot" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_fert_use.dta", replace ******************************************************************************** * IMPROVED SEED USE * ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear gen imprv_seed_use=. replace imprv_seed_use=1 if s4q11==2 | s4q11==3 | s4q11==4 //KEF: W4 has more disaggregation for "improved", including Improved/New, Improved/Recycled, and Improved/Leftover. However, the numbering of this disaggregation in Stata is different than how it is listed in the instrument, so these may not line up correctly. replace imprv_seed_use=0 if s4q11==1 @@ -2689,18 +3788,18 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_improvedseed_use.dta", rep *Seed adoption by farmers (a farmer is an individual listed as plot manager) *KEF: The following is Andrew's new code for this section, to avoid challenges with "wide" data encoding. -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear ren s4q01b crop_code gen all_imprv_seed_use = (s4q11==2 | s4q11==3 | s4q11==4) //KEF: Same issue as in line 2084. Andrew recommended to change this to imprv_seed_use since it makes things below slightly easier, however all other sections used this nomenclature so decided to keep the "all" in there. replace all_imprv_seed_use=. if s4q11==. gen all_hybrid_seed_use=. //KEF: Doesn't ask about hybrid seeds, but want to avoid a missing variable error later in the summary stats. ren saq09 personid -gen farm_manager=1 +*gen farm_manager=1 merge m:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gender_merge_both.dta", nogen keep(1 3) -recode farm_manager (.=0) +*recode farm_manager (.=0) //First part preserve - collapse (max) all_imprv_seed_use all_hybrid_seed_use farm_manager, by(household_id personid female) //This takes care of dropping extraneous variables. If we want hybrid seed use to be in here, it should be consistent and include it throughout to increase code portability as well in case hybrid seeds are added in later versions. + collapse (max) all_imprv_seed_use all_hybrid_seed_use /*farm_manager*/, by(household_id personid female) //This takes care of dropping extraneous variables. If we want hybrid seed use to be in here, it should be consistent and include it throughout to increase code portability as well in case hybrid seeds are added in later versions. gen female_imprv_seed_use = all_imprv_seed_use==1 if female==1 gen female_hybrid_seed_use = all_hybrid_seed_use==1 if female==1 gen male_imprv_seed_use = all_imprv_seed_use==1 if female==0 @@ -2708,14 +3807,14 @@ preserve lab var all_imprv_seed_use "1 = Individual farmer (plot manager) uses improved seeds" lab var male_imprv_seed_use "1 = Individual male farmers (plot manager) uses improved seeds" lab var female_imprv_seed_use "1 = Individual female farmers (plot manager) uses improved seeds" - lab var farm_manager "1 = Individual is listed as a manager for at least one plot" + *lab var farm_manager "1 = Individual is listed as a manager for at least one plot" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_improvedseed_use.dta", replace restore //Now for monocropped plots ren all_imprv_seed_use all_imprv_seed_ //Since "use" in the same file with `cn' implies that "use" is a member of the top crops. ren all_hybrid_seed_use all_hybrid_seed_ -collapse (max) all_imprv_seed_ all_hybrid_seed_, by(household_id personid farm_manager female crop_code) +collapse (max) all_imprv_seed_ all_hybrid_seed_, by(household_id personid /*farm_manager*/ female crop_code) gen farmer_ = 1 gen crop="" forvalues k=1(1)$nb_topcrops { @@ -2730,17 +3829,17 @@ drop crops*/ drop crop_code drop if crop=="" //ALT: This is where I would stop -reshape wide all_imprv_seed_ all_hybrid_seed_ farmer_, i(household_id personid farm_manager female) j(crop) string //Now we have all crops, not just the BMGF ones. //KEF error here, option i not allowed +reshape wide all_imprv_seed_ all_hybrid_seed_ farmer_, i(household_id personid /*farm_manager*/ female) j(crop) string //Now we have all crops, not just the BMGF ones. //KEF error here, option i not allowed ren farmer_* *_farmer // Andrew suggested to switch these around, not best practice. recode *_farmer (.=0) - lab var farm_manager "1 = Individual is listed as a manager for at least one plot" + *lab var farm_manager "1 = Individual is listed as a manager for at least one plot" forvalues k=1(1)$nb_topcrops { local c: word `k' of $topcrop_area local cn: word `k' of $topcropname_area local cnfull: word `k' of $topcropname_ull preserve - keep *`cn'* household_id personid farm_manager female + keep *`cn'* household_id personid /*farm_manager*/ female gen female_imprv_seed_`cn'=all_imprv_seed_`cn' if female==1 gen male_imprv_seed_`cn' = all_imprv_seed_`cn' if female==0 recode male* female* (.=0) @@ -2751,7 +3850,7 @@ restore // This should run much more quickly than the old code because we're min } /* Old code -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear gen all_imprv_seed_use = (s4q11==2 | s4q11==3 | s4q11==4) //KEF: Same issue as in line 2084. Andrew recommended to change this to imprv_seed_use since it makes things below slightly easier, however all other sections used this nomenclature so decided to keep the "all" in there. replace all_imprv_seed_use=. if s4q11==. ren saq09 farmerid @@ -2771,7 +3870,7 @@ recode farm_manager (.=0) lab var farm_manager "1=Indvidual is listed as a manager for at least one plot" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmer_improvedseed_use.dta", replace -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear gen all_imprv_seed_use=. replace all_imprv_seed_use=1 if s4q11==2 | s4q11==3 | s4q11==4 //KEF: Same issue as in line 2084. replace all_imprv_seed_use=0 if s4q11==1 @@ -2805,15 +3904,17 @@ forvalues k=1(1)$nb_topcrops { } */ - +*/ ******************************************************************************** * REACHED BY AG EXTENSION * ******************************************************************************** *BET 05.05.21 -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect7_pp_W4.dta", nogen +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear +//ALT QUICK FIX +destring saq09, replace +merge m:1 household_id holder_id using "$Ethiopia_ESS_W4_temp_data/sect7_pp_W4.dta", nogen //DYA 7.3.2023 change m:m to m:1 but no implication for the rest of the code gen ext_reach_all=0 replace ext_reach_all=1 if s3q16==1 | s7q04==1 | s7q09==1 @@ -2841,12 +3942,12 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_any_ext.dta", replace * MOBILE OWNERSHIP* ******************************************************************************** *BET 05.04.21 -use "${Ethiopia_ESS_W4_raw_data}/Household/sect10a_hh_w4.dta", clear +use "${Ethiopia_ESS_W4_temp_data}/sect10a_hh_W4.dta", clear recode s10aq41 (.=0) gen mobile_owned=s10aq41==1 preserve -use "${Ethiopia_ESS_W4_raw_data}/Household/sect11b1_hh_w4.dta", clear +use "${Ethiopia_ESS_W4_temp_data}/sect11b1_hh_W4.dta", clear recode s11b_ind_01 s11b_ind_02 (.=0) gen mobile_owned=s11b_ind_01==1 gen idv_number_mobile_owned = s11b_ind_02 @@ -2866,14 +3967,14 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_2018_mobile_own", replace * FORMAL FINANCIAL SERVICES USE * ******************************************************************************** * BET 05.05.21 - CHECK CONFIRM THAT USE QUESTIONS SHOULD MERGE IN ANY QUESTION ABOUT USE OF ACCOUNTS -use "$Ethiopia_ESS_W4_raw_data/Household/sect5a_hh_W4.dta", clear -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect5b1_hh_W4.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect5b2_hh_W4.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect11b2_hh_W4.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect12b1_hh_W4.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect13_hh_W4_v2.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect4_hh_W4.dta", nogen -merge m:m household_id using "$Ethiopia_ESS_W4_raw_data/Household/sect15b_hh_W4.dta", nogen +use "$Ethiopia_ESS_W4_temp_data/sect5a_hh_W4.dta", clear +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect5b1_hh_W4.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect5b2_hh_W4.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect11b2_hh_W4.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect12b1_hh_W4.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect13_hh_W4_v2.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect4_hh_W4.dta", nogen +merge m:m household_id using "$Ethiopia_ESS_W4_temp_data/sect15b_hh_W4.dta", nogen gen borrow_bank = s15q02b==9 | s12bq07_1 ==6 | s12bq07_2 == 6 gen borrow_micro = s12bq07_1 ==9 | s12bq07_2 == 9 | s15q02b == 7 // other uses s5aq06__3==1 | s5aq11__3==1 | (s5bq01 == 1 & asset_type ==3) | gen borrow_mortgage = . @@ -2912,7 +4013,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fin_serv.dta", replace * MILK PRODUCTIVITY * ******************************************************************************** * BET 05.14.2021 -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_W4.dta", clear gen cows = ls_code==3 keep if cows gen milk_animals = ls_s8_4_q02 // number of livestock milked (by holder) in last year @@ -2931,7 +4032,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_milk_animals.dta", replace * EGG PRODUCTIVITY * ******************************************************************************** * BET 05.14.2021 -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_W4.dta", clear gen clutching_periods = ls_s8_4q14 // number of clutching periods per hen in last 12 months gen eggs_clutch = ls_s8_4q15 // number of eggs per clutch gen hen_total = ls_s8_4q16 // total laying hens @@ -2943,13 +4044,13 @@ lab var hen_total "Total number of laying hens" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_eggs_animals.dta", replace - +/* ALT: Old ******************************************************************************** * CROP PRODUCTION COSTS PER HECTARE * ******************************************************************************** //KEF 7.15.21 *Land rental rates -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", clear //drop if pp_s2q01b==2 KEF: Getting rid of this line (parcel no longer owned or rented) since this is the first wave in the new survey stream. ren s2q15a land_rental_income_cash ren s2q15b land_rental_income_inkind @@ -3058,7 +4159,7 @@ lab var value_rented_land_mixed "Value of rented land (household expenditures) f save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_rental_value.dta", replace *Value of area planted -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear gen pure_stand = s4q02==1 gen any_pure = pure_stand==1 gen any_mixed = pure_stand==0 @@ -3101,7 +4202,7 @@ gen ha_planted_female_mixed = percent_field*area_meas_hectares if dm_gender==2 & gen ha_planted_mixed_mixed = percent_field*area_meas_hectares if dm_gender==3 & any_mixed==1 *Merging in sect2 for rental variables -merge m:1 holder_id parcel_id using "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", gen(sect2_merge) keep(1 3) // 173 not matched from master +merge m:1 holder_id parcel_id using "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", gen(sect2_merge) keep(1 3) // 173 not matched from master *Merging in rental rate merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_rental_rate.dta", nogen keep(1 3) keepusing(ha_rental_rate) *Value of all OWNED (that is, not rented) land @@ -3125,7 +4226,7 @@ lab var value_owned_land_mixed "Value of owned land that was cultivated (mixed-m save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_land.dta", replace *Post planting expenses - implicit and explicit -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear *Fertilizer expenses (EXPLICIT) ren s3q21d value_urea ren s3q22d value_DAP @@ -3202,7 +4303,7 @@ egen days_hired_pp = rowtotal(days_men days_women days_children) *Value of family labor (IMPLICIT) preserve *To do family labor, we first need to merge in individual gender -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect1_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_pp_W4.dta", clear ren s1q00 pid drop if pid==. isid holder_id pid // check @@ -3347,7 +4448,7 @@ lab var days_nonhired_pp_mixed "Days of pre-harvest non-hired labor used on mixe save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_pp_inputs_value.dta", replace *Harvest labor costs -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect10_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect10_ph_W4.dta", clear *Hired labor (EXPLICIT) ren s10q01a number_men ren s10q01b number_days_men @@ -3409,7 +4510,7 @@ foreach i in male female child{ } *To do family labor, we first need to merge in individual gender preserve -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect1_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect1_ph_W4.dta", clear ren s1q00 pid drop if pid==. isid holder_id pid // check @@ -3545,7 +4646,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_harv_labor.dta", r *Cost of seeds *Purchased, free, and left-over seeds are all seeds used (see question 19 in section 5) -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect5_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect5_pp_W4.dta", clear recode s5q04 s5q13 s5q17 (.=0) *gen kg_seed_purchased = pp_s5q05_a + pp_s5q05_b/1000 // kg + g/1000 KEF: Unnecessary because already in kg. gen kg_seed_purchased = s5q04 @@ -3596,13 +4697,52 @@ lab var value_transport_free_seed "Cost of transport for free seed" lab var value_purchased_seed "Value of seed purchased (household)" lab var value_non_purchased_seed "Value of seed not purchased (household)" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_seed.dta", replace +*/ +******************************************************************************** +* CROP PRODUCTION COSTS PER HECTARE * +******************************************************************************** +*All the preprocessing is done in the crop expenses section +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear +collapse (sum) ha_planted ha_harvest, by(hhid holder_id parcel_id field_id purestand field_size) +reshape long ha_, i(hhid holder_id parcel_id field_id purestand field_size) j(area_type) string +tempfile field_areas +save `field_areas' + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_cost_inputs_long.dta", clear +collapse (sum) cost_=val, by(hhid holder_id parcel_id field_id dm_gender exp) +reshape wide cost_, i(hhid holder_id parcel_id field_id dm_gender) j(exp) string +recode cost_exp cost_imp (.=0) +gen cost_total=cost_imp+cost_exp +drop cost_imp +merge 1:m hhid holder_id parcel_id field_id using `field_areas', nogen keep(3) +//reshape long cost_, i(hhid plot_id dm_gender) j(exp) string +//replace cost_ = cost_/ha_ +gen cost_exp_ha_ = cost_exp/ha_ +gen cost_total_ha_ = cost_total/ha_ +collapse (mean) cost*ha_ [aw=field_size], by(hhid dm_gender area_type) +gen dm_gender2 = "male" //No missings here, so this should be fine. +replace dm_gender2 = "female" if dm_gender==2 +replace dm_gender2 = "mixed" if dm_gender==3 +drop dm_gender +replace area_type = "harvested" if strmatch(area_type,"harvest") +reshape wide cost*_, i(hhid dm_gender2) j(area_type) string +ren cost* cost*_ +reshape wide cost*, i(hhid) j(dm_gender2) string + +foreach i in male female mixed { + foreach j in planted harvested { + la var cost_exp_ha_`j'_`i' "Explicit cost per hectare by area `j', `i'-managed plots" + la var cost_total_ha_`j'_`i' "Total cost per hectare by area `j', `i'-managed plots" + } +} +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropcosts.dta", replace ******************************************************************************** *AGRICULTURAL WAGES ******************************************************************************** -use "${Ethiopia_ESS_W4_raw_data}/Post-Planting/sect3_pp_W4.dta", clear -append using "${Ethiopia_ESS_W4_raw_data}/Post-Harvest/sect10_ph_W4.dta" +use "${Ethiopia_ESS_W4_temp_data}/sect3_pp_W4.dta", clear +append using "${Ethiopia_ESS_W4_temp_data}/sect10_ph_W4.dta" *Hired Labor post-planting ren s3q30a number_men_pp ren s3q30b number_days_men_pp @@ -3643,10 +4783,69 @@ lab var wage_paid_aglabor_male "Daily agricultural wage paid for male hired labo save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_ag_wage.dta", replace +******************************************************************************** +* RATE OF FERTILIZER APPLICATION * +******************************************************************************** +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear +collapse (sum) ha_planted, by(hhid holder_id parcel_id field_id dm_gender) + +merge 1:1 hhid holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_quantities.dta", nogen keep(1 3) //11 plots have expenses but don't show up in the all_plots roster. //MGM 5.18.2024: 80 not matched, 10,527 matched +//codebook dm_gender +//Winsorization is necessary here because small plots generated either from lack of GPS measurement or bad nonstandard unit conversion factors can seriously distort the estimates. +merge m:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", keep (1 3) nogen +_pctile ha_planted [aw=weight] if ha_planted!=0 , p($wins_lower_thres $wins_upper_thres) +gen w_ha_planted = ha_planted +replace w_ha_planted =r(r1) if w_ha_planted < r(r1) & w_ha_planted !=. & w_ha_planted !=0 +replace w_ha_planted = r(r2) if w_ha_planted > r(r2) & w_ha_planted !=. +//This "rate" juggle occurs for backwards compatibility, where the rate variables were previously just the quantity applied +ren *_rate *_kg_ + +gen dm_gender2 = "male" if dm_gender==1 +replace dm_gender2 = "female" if dm_gender==2 +replace dm_gender2 = "mixed" if dm_gender==3 +replace dm_gender2 = "other" if dm_gender==. +drop dm_gender +ren ha_planted ha_planted_ +ren w_ha_planted w_ha_planted_ + +reshape wide *_, i(hhid holder_id parcel_id field_id) j(dm_gender2) string +recode ha_planted* (0=.) +collapse (rawsum) *planted* *kg*, by(hhid) + +foreach i in fert_inorg fert_org herb pest fung { + foreach j in male female mixed { + gen `i'_rate_`j' = `i'_kg_`j'/w_ha_planted_`j' +} +} + + +foreach i in w_ha_planted ha_planted fert_inorg_kg fert_org_kg pest_kg herb_kg fung_kg { + egen `i' = rowtotal(`i'_*) +} +drop *other* //Need this for household totals but otherwise we don't track plots with unknown management +//Some high inorg fert rates as a result of large tonnages on small plots. +lab var fert_inorg_kg "Inorganic fertilizer (kgs) for household" +lab var fert_org_kg "Organic fertilizer (kgs) for household" +lab var pest_kg "Pesticide (kgs) for household" +lab var herb_kg "Herbicide (kgs) for household" +lab var fung_kg "Fungicide (kgs) for household" +lab var ha_planted "Area planted (ha), all crops, for household" + +foreach i in male female mixed { +lab var fert_inorg_kg_`i' "Inorganic fertilizer (kgs) for `i'-managed plots" +lab var fert_org_kg_`i' "Organic fertilizer (kgs) for `i'-managed plots" +lab var pest_kg_`i' "Pesticide (kgs) for `i'-managed plots" +lab var herb_kg_`i' "Herbicide (kgs) for `i'-managed plots" +lab var fung_kg_`i' "Fungicide (kgs) for `i'-managed plots" +lab var ha_planted_`i' "Area planted (ha), all crops, `i'-managed plots" +} +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fertilizer_application.dta", replace + +/*ALT: Old ******************************************************************************** * FERTILIZER APPLICATION (KG) ******************************************************************************** -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear *Merging in gender merge m:1 holder_id parcel_id field_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_field_gender_dm.dta", nogen *For fertilizer @@ -3694,7 +4893,7 @@ lab var fert_inorg_kg_female "Inorganic fertilizer (kgs) for female-managed plot lab var fert_inorg_kg_mixed "Inorganic fertilizer (kgs) for mixed-managed plots" lab var use_inorg_fert "Household uses any inorganic fertilizer" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fertilizer_application.dta", replace - +*/ ******************************************************************************** *WOMEN'S DIET QUALITY @@ -3707,7 +4906,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fertilizer_application.dta * DIETARY DIVERSITY ******************************************************************************** // updated for W4 by BET 05.04.2021 -use "$Ethiopia_ESS_W4_raw_data/Household/sect6a_hh_W4.dta" , clear +use "$Ethiopia_ESS_W4_temp_data/sect6a_hh_W4.dta" , clear * We recode food items to map HDD food categories CHECK @@ -3762,7 +4961,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_household_diet.dta", repla *WOMEN'S OWNERSHIP OF ASSETS ******************************************************************************** * FEMALE LAND OWNERSHIP -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect2_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect2_pp_W4.dta", clear *Female asset ownership local landowners "s2q07_1 s2q07_2 s2q09_1 s2q09_2" // sell, collateral, or bequeath. cannot answer gender of owner for rented land, because does not use network roster BET 05.04.2021 keep household_id `landowners' // keep relevant variable @@ -3788,7 +4987,7 @@ gen type_asset="land" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_land_owner.dta", replace *FEMALE LIVESTOCK OWNERSHIP -use "$Ethiopia_ESS_W4_raw_data/sect8_1_ls_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_1_ls_W4.dta", clear *Remove poultry-livestocks--cocks, hens, chicks drop if inlist(ls_code,10,11,12,.) local livestockowners "ls_s8_1q04_1 ls_s8_1q04_2" @@ -3815,7 +5014,7 @@ gen type_asset="livestock" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_livestock_owner.dta", replace * FEMALE OTHER ASSETS -use "$Ethiopia_ESS_W4_raw_data/Household/sect11_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_hh_W4.dta", clear *keep only productive assets drop if inlist(asset_cd,4,5,6,7,8,9,10,11,12,23,24,25,26.) //exclude blanket, mattress, watches, sofa, handcart, jewelry. What about radio/TV/CD/satellite? BET 05.04.2021 CHECK local otherassetowners "s11q02_1 s11q02_2 s11q02_3 s11q02_4 s11q02_5 s11q02_6 s11q02_7 s11q02_8 s11q02_9 s11q02_10 s11q02_11 s11q02_12" @@ -3852,7 +5051,7 @@ collapse (max) own_asset, by(household_id asset_owner) gen individual_id =asset_owner *Own any asset *Now merge with member characteristics -merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_raw_data/Household/sect1_hh_W4.dta" +merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_temp_data/sect1_hh_W4.dta" keep household_id individual_id own_asset asset_owner ea_id saq14 pw_w4 saq01 saq02 saq03 saq04 saq05 saq06 saq07 saq08 s1q01 s1q02 s1q03a ren s1q02 mem_gender ren s1q03a age @@ -3862,8 +5061,8 @@ ren saq02 zone recode own_asset (.=0) gen women_asset= own_asset==1 & mem_gender==2 lab var women_asset "Women ownership of asset" -drop if mem_gender==1 -drop if age<18 & mem_gender==2 +*drop if mem_gender==1 +*drop if age<18 & mem_gender==2 gen personid= individual_id compress save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_asset.dta", replace @@ -3873,7 +5072,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_asset.dta", replace *WOMEN'S AG DECISION-MAKING ******************************************************************************** *SALES DECISION-MAKERS - INPUT DECISIONS -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect3_pp_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect3_pp_W4.dta", clear *Women's decision-making in ag local planting_input "s3q13 s3q15_1 s3q15_2" keep household_id saq09 `planting_input' // keep relevant variables @@ -3899,7 +5098,7 @@ gen type_decision="planting_input" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_planting_input.dta", replace *SALES DECISION-MAKERS - ANNUAL SALES -- "Who in HH decided what to do with earnings for field crop" -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect11_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_ph_W4.dta", clear local control_annualsales "s11q13_1 s11q13_2" keep household_id saq09 `control_annualsales' // keep relevant variables * Transform the data into long form @@ -3924,7 +5123,7 @@ gen type_decision="control_annualsales" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_annualsales.dta", replace *SALES DECISION-MAKERS - ANNUAL CROP -- "Who in HH made decisions about selling" -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect11_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect11_ph_W4.dta", clear local sales_annualcrop "s11q08_1 s11q08_2" keep household_id saq09 `sales_annualcrop' // keep relevant variables * Transform the data into long form @@ -3951,7 +5150,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_sales_annualcrop.dta /* no section on perm crops, trees and roots include in previous section *SALES DECISION-MAKERS - PERM SALES (TREES/FRUIT/VEG) --"Who in HH decided what to do with earnings" -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect12_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect12_ph_W4.dta", clear local control_permsales "ph_s12q08a_1 ph_s12q08a_2" keep household_id saq09 `control_permsales' // keep relevant variables * Transform the data into long form @@ -3976,7 +5175,7 @@ gen type_decision="control_permsales" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_permsales.dta", replace *SALES DECISION-MAKERS - PERM CROP -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect12_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect12_ph_W4.dta", clear local sales_permcrop "ph_saq07 ph_s12q08a_1 ph_s12q08a_2" keep household_id saq09 `sales_permcrop' // keep relevant variables * Transform the data into long form @@ -4002,7 +5201,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_sales_permcrop.dta", */ *SALES DECISION-MAKERS - HARVEST -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear local harvest "s9q09_1 s9q09_2" keep household_id saq09 `harvest' // keep relevant variables * Transform the data into long form @@ -4027,7 +5226,7 @@ gen type_decision="harvest" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_harvest.dta", replace *SALES DECISION-MAKERS - ANNUAL HARVEST -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear local control_annualharvest "s9q09_1 s9q09_2" keep household_id saq09 `control_annualharvest' // keep relevant variables * Transform the data into long form @@ -4052,7 +5251,7 @@ gen type_decision="control_annualharvest" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_annualharvest.dta", replace * FEMALE LIVESTOCK DECISION-MAKING - MANAGEMENT -use "$Ethiopia_ESS_W4_raw_data/sect8_1_ls_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_1_ls_W4.dta", clear local livestockowners "ls_s8_1q05_1 ls_s8_1q05_2" keep household_id saq09 `livestockowners' // keep relevant variables * Transform the data into long form @@ -4098,7 +5297,7 @@ collapse (max) make_decision_* , by(household_id decision_maker ) //any decisio ren decision_maker individual_id *Now merge with member characteristics -merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_raw_data/Household/sect1_hh_W4.dta" +merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_temp_data/sect1_hh_W4.dta" drop s1q03b- _merge recode make_decision_* (.=0) @@ -4106,8 +5305,8 @@ recode make_decision_* (.=0) ren s1q02 mem_gender ren s1q03a age gen female = mem_gender==2 -drop if mem_gender==1 -drop if age<18 & mem_gender==2 +*drop if mem_gender==1 +*drop if age<18 & mem_gender==2 *Generate women control over income local allactivity crop livestock ag foreach v of local allactivity { @@ -4126,7 +5325,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_ag_decision.dta", replace ******************************************************************************** /* * FEMALE LIVESTOCK DECISION-MAKING - SALES -use "$Ethiopia_ESS_W4_raw_data/sect8_4_ls_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect8_4_ls_W4.dta", clear local control_livestocksales "ls_sec_8_1q03_a ls_sec_8_1q03_b" keep household_id saq09 `control_livestocksales' // keep relevant variables * Transform the data into long form @@ -4152,7 +5351,7 @@ save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_livestocksal */ * FEMALE DECISION-MAKING - CONTROL OF BUSINESS INCOME -use "$Ethiopia_ESS_W4_raw_data/Household/sect12b1_hh_W4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect12b1_hh_W4.dta", clear local control_businessincome "s12bq06_1 s12bq06_2" keep household_id `control_businessincome' // keep relevant variables * Transform the data into long form @@ -4177,7 +5376,7 @@ gen type_decision="control_businessincome" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_control_businessincome.dta", replace * FEMALE DECISION-MAKING - CONTROL OF OTHER INCOME -use "$Ethiopia_ESS_W4_raw_data/Household/sect13_hh_W4_v2.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect13_hh_W4_v2.dta", clear local control_otherincome "s13q03_1 s13q03_2" keep household_id `control_otherincome' // keep relevant variables * Transform the data into long form @@ -4242,13 +5441,13 @@ drop _m ren controller_income individual_id *Now merge with member characteristics -merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_raw_data/Household/sect1_hh_W4.dta" +merge 1:1 household_id individual_id using "$Ethiopia_ESS_W4_temp_data/sect1_hh_W4.dta" drop s1q03b-_merge ren s1q02 mem_gender ren s1q03a age gen female = mem_gender==2 -drop if mem_gender==1 -drop if age<18 & mem_gender==2 +*drop if mem_gender==1 +*drop if age<18 & mem_gender==2 recode control_* (.=0) gen women_control_all_income= control_all_income==1 gen personid = individual_id @@ -4261,13 +5460,13 @@ lab var control_nonfarmincome "1=invidual has control over non-farm (business or lab var control_all_income "1=invidual has control over at least one type of income" save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_control_income.dta", replace - +/* ALT: Old ******************************************************************************** *CROP YIELDS ******************************************************************************** *BET 07.16.2021 *Starting with crops -use "$Ethiopia_ESS_W4_raw_data/Post-Planting/sect4_pp_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect4_pp_W4.dta", clear *Percent of area gen pure_stand = s4q02==1 gen any_pure = pure_stand==1 @@ -4317,21 +5516,10 @@ ren s4q19 number_trees_planted keep ha_planted* holder_id parcel_id field_id household_id crop_id dm_* any_* number_trees_planted intercropped_yn save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_area_planted.dta", replace -*Before harvest, need to prepare the conversion factors -use "${Ethiopia_ESS_W4_created_data}/Crop_CF_Wave4_adj.dta", clear -ren mean_cf_nat mean_cf100 -sort crop_code unit_cd mean_cf100 -duplicates drop crop_code unit_cd, force -*BET 07.16.2021 CHECK HERE: there are two regions that appear in PH files that do not appear in the conversion files (13. Harar, 15. Dire Dawa) but these use the same conversion factor as Somalie which is recoded to 5 -gen mean_cf13= mean_cf99 // -gen mean_cf15 = mean_cf99 -reshape long mean_cf, i(crop_code unit_cd) j(region) -recode region (99=5) -ren mean_cf conversion -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cf.dta", replace + *Now to harvest -use "$Ethiopia_ESS_W4_raw_data/Post-Harvest/sect9_ph_w4.dta", clear +use "$Ethiopia_ESS_W4_temp_data/sect9_ph_W4.dta", clear ren saq01 region ren s9q00b crop_code ren s9q05b unit_cd @@ -4933,147 +6121,1692 @@ foreach x of varlist value_pro* { local l`x'= subinstr("`l`x''","value_pro, type_commodity == ","Value of production, ",.) lab var `x' "`l`x''" } -foreach x of varlist value_sal* { - local l`x':var label `x' - local l`x'= subinstr("`l`x''","value_sal, type_commodity == ","Value of sales, ",.) - lab var `x' "`l`x''" +foreach x of varlist value_sal* { + local l`x':var label `x' + local l`x'= subinstr("`l`x''","value_sal, type_commodity == ","Value of sales, ",.) + lab var `x' "`l`x''" +} + +qui recode value_* (.=0) +foreach x of varlist value_* { + local l`x':var label `x' +} + +qui recode value_* (.=0) +collapse (sum) value_*, by(household_id) +foreach x of varlist value_* { + lab var `x' "`l`x''" +} +drop value_pro value_sal +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_type_crop.dta", replace +*End BET 07.19.2021 + +*/ + + + + +******************************************************************************** +*CROP YIELDS +******************************************************************************** +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear +ren crop_code_master crop_code +gen number_trees_planted_banana = number_trees_planted if crop_code==42 +gen number_trees_planted_cassava = number_trees_planted if crop_code==10 +// gen number_trees_planted_cocoa = number_trees_planted if crop_code==3040 *MGM 5.18.2024: cocoa is not in W4? Need to revisit this and see if cocoa is in tree crop codes in W4? +recode number_trees_planted_banana number_trees_planted_cassava /*number_trees_planted_cocoa*/ (.=0) +collapse (sum) number_trees_planted*, by(hhid) +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_trees.dta", replace + +* MGM 5.20.2024: Note that I had to change this up a little bit from how it was done in Nigeria because we do not have dm_gender information for all plots! Output still looks identical. Mainly, the difference is that if you aggregate any variables using gender up to the hh level, you won't get the same number as hh total numbers for households with missing dm_gender on any plot. +**# Bookmark #2 + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_all_fields.dta", clear +ren crop_code_master crop_code +//Legacy stuff- agquery gets handled above. +collapse (sum) area_harv_=ha_harvest area_plan_=ha_planted harvest_=quant_harv_kg, by(hhid dm_gender purestand crop_code) +gen mixed = "inter" if purestand==0 +replace mixed="pure" if purestand==1 +gen dm_gender2="male" if dm_gender == 1 +replace dm_gender2="female" if dm_gender==2 +replace dm_gender2="mixed" if dm_gender==3 +replace dm_gender2="other" if dm_gender==. //ALT 07.08.24 +drop dm_gender purestand + +preserve +collapse (sum) area_harv=area_harv_ area_plan=area_plan_ harvest=harvest_, by(hhid crop_code) +tempfile hh_tots +save `hh_tots' +restore + +preserve +collapse (sum) area_harv_ area_plan_ harvest_, by(hhid crop_code mixed) +reshape wide harvest_ area_harv_ area_plan_, i(hhid crop_code) j(mixed) string +tempfile area_planharv_stand +save `area_planharv_stand' +restore + +preserve +drop if dm_gender2 == "" // 98 observations deleted - for these households, totals will be greater than the sum of male, female, mixed +collapse (sum) area_harv_ area_plan_ harvest_, by(hhid crop_code dm_gender2) +reshape wide harvest_ area_harv_ area_plan_, i(hhid crop_code) j(dm_gender2) string +tempfile area_planharv_gender +save `area_planharv_gender' +restore + +//drop if dm_gender2=="" // 98 observations deleted - for these households, totals will be greater than the sum of male, female, mixed +reshape wide harvest_ area_harv_ area_plan_, i(hhid dm_gender2 crop_code) j(mixed) string +ren area* area*_ +ren harvest* harvest*_ + +//drop value_harvest kgs_harvest value_sold kgs_sold +reshape wide harvest* area*, i(hhid crop_code) j(dm_gender2) string + +merge 1:1 hhid crop_code using `hh_tots', nogen +merge 1:1 hhid crop_code using `area_planharv_stand', nogen // want to keep all here bc households in using don't have dm_gender and won't merge accordingly +merge 1:1 hhid crop_code using `area_planharv_gender', nogen // want to keep all here bc households in using don't have dm_gender and won't merge accordingly + +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_area_plan.dta", replace + +*Total planted and harvested area summed across all plots, crops, and seasons. +preserve + collapse (sum) all_area_harvested=area_harv all_area_planted=area_plan, by(hhid) + replace all_area_harvested=all_area_planted if all_area_harvested>all_area_planted & all_area_harvested!=. + save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_area_planted_harvested_allcrops.dta", replace +restore +keep if inlist(crop_code, $comma_topcrop_area) +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_harvest_area_yield.dta", replace + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_harvest_area_yield.dta", clear +*Value of crop production +merge m:1 crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropname_table.dta", nogen keep(1 3) +merge 1:1 hhid crop_code using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production.dta", nogen keep(1 3) +ren value_crop_production value_harv_ +ren value_crop_sales value_sold_ +foreach i in harvest area { + ren `i'* `i'*_ +} +gen total_planted_area_ = area_plan_ +gen total_harv_area_ = area_harv_ +gen kgs_harvest_ = harvest_ + +drop crop_code value_harvest kgs_harvest value_sold kgs_sold +unab vars : *_ +reshape wide `vars', i(hhid) j(crop_name) string +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_trees.dta" +collapse (sum) harvest* area_harv* area_plan* total_planted_area* total_harv_area* kgs_harvest* value_harv* value_sold* number_trees_planted* , by(hhid) +recode harvest* area_harv* area_plan* kgs_harvest* total_planted_area* total_harv_area* value_harv* value_sold* (0=.) +egen kgs_harvest = rowtotal(kgs_harvest_*) +la var kgs_harvest "Quantity harvested of all crops (kgs) (household) (summed across all seasons)" + +*label variables +foreach p of global topcropname_area { + lab var value_harv_`p' "Value harvested of `p' (ETB) (household)" + lab var value_sold_`p' "Value sold of `p' (ETB) (household)" + lab var kgs_harvest_`p' "Quantity harvested of `p' (kgs) (household)" + //lab var kgs_sold_`p' "Quantity sold of `p' (kgs) (household)" + lab var total_harv_area_`p' "Total area harvested of `p' (ha) (household)" + lab var total_planted_area_`p' "Total area planted of `p' (ha) (household)" + lab var harvest_`p' "Quantity harvested of `p' (kgs) (household)" + lab var harvest_male_`p' "Quantity harvested of `p' (kgs) (male-managed plots)" + lab var harvest_female_`p' "Quantity harvested of `p' (kgs) (female-managed plots)" + lab var harvest_mixed_`p' "Quantity harvested of `p' (kgs) (mixed-managed plots)" + lab var harvest_pure_`p' "Quantity harvested of `p' (kgs) - purestand (household)" + lab var harvest_pure_male_`p' "Quantity harvested of `p' (kgs) - purestand (male-managed plots)" + lab var harvest_pure_female_`p' "Quantity harvested of `p' (kgs) - purestand (female-managed plots)" + lab var harvest_pure_mixed_`p' "Quantity harvested of `p' (kgs) - purestand (mixed-managed plots)" + lab var harvest_inter_`p' "Quantity harvested of `p' (kgs) - intercrop (household)" + lab var harvest_inter_male_`p' "Quantity harvested of `p' (kgs) - intercrop (male-managed plots)" + lab var harvest_inter_female_`p' "Quantity harvested of `p' (kgs) - intercrop (female-managed plots)" + lab var harvest_inter_mixed_`p' "Quantity harvested of `p' (kgs) - intercrop (mixed-managed plots)" + lab var area_harv_`p' "Area harvested of `p' (ha) (household)" + lab var area_harv_male_`p' "Area harvested of `p' (ha) (male-managed plots)" + lab var area_harv_female_`p' "Area harvested of `p' (ha) (female-managed plots)" + lab var area_harv_mixed_`p' "Area harvested of `p' (ha) (mixed-managed plots)" + lab var area_harv_pure_`p' "Area harvested of `p' (ha) - purestand (household)" + lab var area_harv_pure_male_`p' "Area harvested of `p' (ha) - purestand (male-managed plots)" + lab var area_harv_pure_female_`p' "Area harvested of `p' (ha) - purestand (female-managed plots)" + lab var area_harv_pure_mixed_`p' "Area harvested of `p' (ha) - purestand (mixed-managed plots)" + lab var area_harv_inter_`p' "Area harvested of `p' (ha) - intercrop (household)" + lab var area_harv_inter_male_`p' "Area harvested of `p' (ha) - intercrop (male-managed plots)" + lab var area_harv_inter_female_`p' "Area harvested of `p' (ha) - intercrop (female-managed plots)" + lab var area_harv_inter_mixed_`p' "Area harvested of `p' (ha) - intercrop (mixed-managed plots)" + lab var area_plan_`p' "Area planted of `p' (ha) (household)" + lab var area_plan_male_`p' "Area planted of `p' (ha) (male-managed plots)" + lab var area_plan_female_`p' "Area planted of `p' (ha) (female-managed plots)" + lab var area_plan_mixed_`p' "Area planted of `p' (ha) (mixed-managed plots)" + lab var area_plan_pure_`p' "Area planted of `p' (ha) - purestand (household)" + lab var area_plan_pure_male_`p' "Area planted of `p' (ha) - purestand (male-managed plots)" + lab var area_plan_pure_female_`p' "Area planted of `p' (ha) - purestand (female-managed plots)" + lab var area_plan_pure_mixed_`p' "Area planted of `p' (ha) - purestand (mixed-managed plots)" + lab var area_plan_inter_`p' "Area planted of `p' (ha) - intercrop (household)" + lab var area_plan_inter_male_`p' "Area planted of `p' (ha) - intercrop (male-managed plots)" + lab var area_plan_inter_female_`p' "Area planted of `p' (ha) - intercrop (female-managed plots)" + lab var area_plan_inter_mixed_`p' "Area planted of `p' (ha) - intercrop (mixed-managed plots)" +} + + +*Indicator variable for whether a household grew each crop +foreach p of global topcropname_area { + gen grew_`p'=(total_harv_area_`p'!=. & total_harv_area_`p'!=0 ) | (total_planted_area_`p'!=. & total_planted_area_`p'!=0) + lab var grew_`p' "1=Household grew `p'" + gen harvested_`p'= (total_harv_area_`p'!=. & total_harv_area_`p'!=.0 ) + lab var harvested_`p' "1= Household harvested `p'" +} + +replace grew_banana =1 if number_trees_planted_banana!=0 & number_trees_planted_banana!=. +foreach p of global cropname { + recode kgs_harvest_`p' (.=0) if grew_`p'==1 + recode value_sold_`p' (.=0) if grew_`p'==1 + recode value_harv_`p' (.=0) if grew_`p'==1 +} +//drop harvest-harvest_pure_mixed area_harv- area_harv_pure_mixed area_plan- area_plan_inter_mixed value_harv kgs_harvest kgs_sold value_sold total_planted_area total_harv_area number_trees_planted_* +//drop ha_planted // AYW 12.10.19 +drop *other* //Only need these for the household totals +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_yield_hh_crop_level.dta", replace + + +* VALUE OF CROP PRODUCTION // using 335 output +//ALT: This part stays in. +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production.dta", clear +*Grouping following IMPACT categories but also mindful of the consumption categories. +gen crop_group="" +replace crop_group= "Barley" if crop_code== 1 +replace crop_group= "Maize" if crop_code== 2 +replace crop_group= "Millet" if crop_code== 3 +replace crop_group= "Other cereals" if crop_code== 4 +replace crop_group= "Other cereals" if crop_code== 5 +replace crop_group= "Sorghum" if crop_code== 6 +replace crop_group= "Teff" if crop_code== 7 +replace crop_group= "Wheat" if crop_code== 8 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 9 +replace crop_group= "Cassava" if crop_code== 10 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 11 +replace crop_group= "Beans" if crop_code== 12 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 13 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 14 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 15 +replace crop_group= "Other other" if crop_code== 16 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 17 +replace crop_group= "Soyabeans" if crop_code== 18 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 19 +replace crop_group= "Spices" if crop_code== 20 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 21 +replace crop_group= "Cotton" if crop_code== 22 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 23 +replace crop_group= "Groundnuts" if crop_code== 24 +replace crop_group= "Spices" if crop_code== 25 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 26 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 27 +replace crop_group= "Oils and fats" if crop_code== 28 +replace crop_group= "Spices" if crop_code== 29 +replace crop_group= "Spices" if crop_code== 30 +replace crop_group= "Spices" if crop_code== 31 +replace crop_group= "Spices" if crop_code== 32 +replace crop_group= "Spices" if crop_code== 33 +replace crop_group= "Spices" if crop_code== 34 +replace crop_group= "Spices" if crop_code== 35 +replace crop_group= "Spices" if crop_code== 36 +replace crop_group= "Spices" if crop_code== 37 +replace crop_group= "Spices" if crop_code== 38 +replace crop_group= "Spices" if crop_code== 39 +replace crop_group= "Spices" if crop_code== 40 +replace crop_group= "Fruits" if crop_code== 41 +replace crop_group= "Bananas and plantains" if crop_code== 42 +replace crop_group= "Fruits" if crop_code== 43 +replace crop_group= "Fruits" if crop_code== 44 +replace crop_group= "Fruits" if crop_code== 45 +replace crop_group= "Fruits" if crop_code== 46 +replace crop_group= "Fruits" if crop_code== 47 +replace crop_group= "Fruits" if crop_code== 48 +replace crop_group= "Fruits" if crop_code== 49 +replace crop_group= "Fruits" if crop_code== 50 +replace crop_group= "Vegetables" if crop_code== 51 +replace crop_group= "Vegetables" if crop_code== 52 +replace crop_group= "Vegetables" if crop_code== 53 +replace crop_group= "Vegetables" if crop_code== 54 +replace crop_group= "Vegetables" if crop_code== 55 +replace crop_group= "Vegetables" if crop_code== 56 +replace crop_group= "Vegetables" if crop_code== 57 +replace crop_group= "Onion" if crop_code== 58 +replace crop_group= "Vegetables" if crop_code== 59 +replace crop_group= "Potato" if crop_code== 60 +replace crop_group= "Vegetables" if crop_code== 61 +replace crop_group= "Sweet potato" if crop_code== 62 +replace crop_group= "Vegetables" if crop_code== 63 +replace crop_group= "Other roots and tubers" if crop_code== 64 +replace crop_group= "Fruits" if crop_code== 65 +replace crop_group= "Fruits" if crop_code== 66 +replace crop_group= "Vegetables" if crop_code== 67 +replace crop_group= "Vegetables" if crop_code== 68 +replace crop_group= "Vegetables" if crop_code== 69 +replace crop_group= "Vegetables" if crop_code== 70 +replace crop_group= "Other other" if crop_code== 71 +replace crop_group= "Coffee" if crop_code== 72 +replace crop_group= "Cotton" if crop_code== 73 +replace crop_group= "Other other" if crop_code== 74 +replace crop_group= "Other other" if crop_code== 75 +replace crop_group= "Sugar" if crop_code== 76 +replace crop_group= "Tea" if crop_code== 77 +replace crop_group= "Other other" if crop_code== 78 +replace crop_group= "Spices" if crop_code== 79 +replace crop_group= "Spices" if crop_code== 80 +replace crop_group= "Spices" if crop_code== 81 +replace crop_group= "Spices" if crop_code== 82 +replace crop_group= "Fruits" if crop_code== 83 +replace crop_group= "Fruits" if crop_code== 84 +replace crop_group= "Other other" if crop_code== 85 +replace crop_group= "Other other" if crop_code== 86 +replace crop_group= "Other other" if crop_code== 97 +replace crop_group= "Yam" if crop_code== 98 +replace crop_group= "Other other" if crop_code== 99 +replace crop_group= "Other other" if crop_code== 100 +replace crop_group= "Other other" if crop_code== 104 +replace crop_group= "Other other" if crop_code== 108 +replace crop_group= "Other other" if crop_code== 110 +replace crop_group= "Other other" if crop_code== 112 +replace crop_group= "Fruits" if crop_code== 113 +replace crop_group= "Other other" if crop_code== 114 +replace crop_group= "Fruits" if crop_code== 115 +replace crop_group= "Other other" if crop_code== 116 +replace crop_group= "Spices" if crop_code== 117 +replace crop_group= "Other nuts, seeds, and pulses" if crop_code== 118 +replace crop_group= "Oils and fats" if crop_code== 119 +replace crop_group= "Other cereals" if crop_code== 120 +replace crop_group= "Other other" if crop_code== 121 +replace crop_group= "Other other" if crop_code== 122 +replace crop_group= "Vegetables" if crop_code== 123 +ren crop_group commodity + + +*High/low value crops +gen type_commodity="" +/* CJS 10.21 revising commodity high/low classification +replace type_commodity= "Low" if crop_code== 1 +replace type_commodity= "Low" if crop_code== 2 +replace type_commodity= "Low" if crop_code== 3 +replace type_commodity= "Low" if crop_code== 4 +replace type_commodity= "Low" if crop_code== 5 +replace type_commodity= "Low" if crop_code== 6 +replace type_commodity= "Low" if crop_code== 7 +replace type_commodity= "Low" if crop_code== 8 +replace type_commodity= "Low" if crop_code== 9 +replace type_commodity= "Low" if crop_code== 10 +replace type_commodity= "Low" if crop_code== 11 +replace type_commodity= "Low" if crop_code== 12 +replace type_commodity= "Low" if crop_code== 13 +replace type_commodity= "Low" if crop_code== 14 +replace type_commodity= "Low" if crop_code== 15 +replace type_commodity= "Low" if crop_code== 16 +replace type_commodity= "Low" if crop_code== 17 +replace type_commodity= "High" if crop_code== 18 +replace type_commodity= "Low" if crop_code== 19 +replace type_commodity= "High" if crop_code== 20 +replace type_commodity= "Low" if crop_code== 21 +replace type_commodity= "High" if crop_code== 22 +replace type_commodity= "Low" if crop_code== 23 +replace type_commodity= "Low" if crop_code== 24 +replace type_commodity= "High" if crop_code== 25 +replace type_commodity= "Low" if crop_code== 26 +replace type_commodity= "Low" if crop_code== 27 +replace type_commodity= "High" if crop_code== 28 +replace type_commodity= "High" if crop_code== 29 +replace type_commodity= "High" if crop_code== 30 +replace type_commodity= "High" if crop_code== 31 +replace type_commodity= "High" if crop_code== 32 +replace type_commodity= "High" if crop_code== 33 +replace type_commodity= "High" if crop_code== 34 +replace type_commodity= "High" if crop_code== 35 +replace type_commodity= "High" if crop_code== 36 +replace type_commodity= "High" if crop_code== 37 +replace type_commodity= "High" if crop_code== 38 +replace type_commodity= "High" if crop_code== 39 +replace type_commodity= "High" if crop_code== 40 +replace type_commodity= "High" if crop_code== 41 +replace type_commodity= "High" if crop_code== 42 +replace type_commodity= "High" if crop_code== 43 +replace type_commodity= "High" if crop_code== 44 +replace type_commodity= "High" if crop_code== 45 +replace type_commodity= "High" if crop_code== 46 +replace type_commodity= "High" if crop_code== 47 +replace type_commodity= "High" if crop_code== 48 +replace type_commodity= "High" if crop_code== 49 +replace type_commodity= "High" if crop_code== 50 +replace type_commodity= "High" if crop_code== 51 +replace type_commodity= "High" if crop_code== 52 +replace type_commodity= "High" if crop_code== 53 +replace type_commodity= "High" if crop_code== 54 +replace type_commodity= "High" if crop_code== 55 +replace type_commodity= "High" if crop_code== 56 +replace type_commodity= "High" if crop_code== 57 +replace type_commodity= "High" if crop_code== 58 +replace type_commodity= "High" if crop_code== 59 +replace type_commodity= "High" if crop_code== 60 +replace type_commodity= "High" if crop_code== 61 +replace type_commodity= "High" if crop_code== 62 +replace type_commodity= "High" if crop_code== 63 +replace type_commodity= "Low" if crop_code== 64 +replace type_commodity= "High" if crop_code== 65 +replace type_commodity= "High" if crop_code== 66 +replace type_commodity= "High" if crop_code== 67 +replace type_commodity= "High" if crop_code== 68 +replace type_commodity= "High" if crop_code== 69 +replace type_commodity= "High" if crop_code== 70 +replace type_commodity= "High" if crop_code== 71 +replace type_commodity= "High" if crop_code== 72 +replace type_commodity= "High" if crop_code== 73 +replace type_commodity= "High" if crop_code== 74 +replace type_commodity= "High" if crop_code== 75 +replace type_commodity= "High" if crop_code== 76 +replace type_commodity= "High" if crop_code== 77 +replace type_commodity= "High" if crop_code== 78 +replace type_commodity= "High" if crop_code== 79 +replace type_commodity= "High" if crop_code== 80 +replace type_commodity= "High" if crop_code== 81 +replace type_commodity= "High" if crop_code== 82 +replace type_commodity= "High" if crop_code== 83 +replace type_commodity= "High" if crop_code== 84 +replace type_commodity= "Low" if crop_code== 85 +replace type_commodity= "Low" if crop_code== 86 +replace type_commodity= "Low" if crop_code== 97 +replace type_commodity= "Low" if crop_code== 98 +replace type_commodity= "Low" if crop_code== 99 +replace type_commodity= "Low" if crop_code== 100 +replace type_commodity= "Low" if crop_code== 104 +replace type_commodity= "Low" if crop_code== 108 +replace type_commodity= "Low" if crop_code== 110 +replace type_commodity= "Low" if crop_code== 112 +replace type_commodity= "High" if crop_code== 113 +replace type_commodity= "High" if crop_code== 114 +replace type_commodity= "High" if crop_code== 115 +replace type_commodity= "High" if crop_code== 116 +replace type_commodity= "High" if crop_code== 117 +replace type_commodity= "Low" if crop_code== 118 +replace type_commodity= "High" if crop_code== 119 +replace type_commodity= "Low" if crop_code== 120 +replace type_commodity= "High" if crop_code== 121 +replace type_commodity= "Low" if crop_code== 122 +replace type_commodity= "High" if crop_code== 123 +*/ + +* CJS 10.21 revising commodity high/low classification +replace type_commodity= "Low" if crop_code== 1 +replace type_commodity= "Low" if crop_code== 2 +replace type_commodity= "Low" if crop_code== 3 +replace type_commodity= "Low" if crop_code== 4 +replace type_commodity= "High" if crop_code== 5 +replace type_commodity= "Low" if crop_code== 6 +replace type_commodity= "Low" if crop_code== 7 +replace type_commodity= "Low" if crop_code== 8 +replace type_commodity= "High" if crop_code== 9 +replace type_commodity= "Low" if crop_code== 10 +replace type_commodity= "High" if crop_code== 11 +replace type_commodity= "High" if crop_code== 12 +replace type_commodity= "High" if crop_code== 13 +replace type_commodity= "High" if crop_code== 14 +replace type_commodity= "High" if crop_code== 15 +replace type_commodity= "High" if crop_code== 16 +replace type_commodity= "High" if crop_code== 17 +replace type_commodity= "High" if crop_code== 18 +replace type_commodity= "High" if crop_code== 19 +replace type_commodity= "High" if crop_code== 20 +replace type_commodity= "High" if crop_code== 21 +replace type_commodity= "Out" if crop_code== 22 +replace type_commodity= "High" if crop_code== 23 +replace type_commodity= "High" if crop_code== 24 +replace type_commodity= "High" if crop_code== 25 +replace type_commodity= "High" if crop_code== 26 +replace type_commodity= "High" if crop_code== 27 +replace type_commodity= "High" if crop_code== 28 +replace type_commodity= "High" if crop_code== 29 +replace type_commodity= "High" if crop_code== 30 +replace type_commodity= "High" if crop_code== 31 +replace type_commodity= "High" if crop_code== 32 +replace type_commodity= "High" if crop_code== 33 +replace type_commodity= "High" if crop_code== 34 +replace type_commodity= "High" if crop_code== 35 +replace type_commodity= "High" if crop_code== 36 +replace type_commodity= "High" if crop_code== 37 +replace type_commodity= "High" if crop_code== 38 +replace type_commodity= "High" if crop_code== 39 +replace type_commodity= "High" if crop_code== 40 +replace type_commodity= "High" if crop_code== 41 +replace type_commodity= "Low" if crop_code== 42 +replace type_commodity= "High" if crop_code== 43 +replace type_commodity= "High" if crop_code== 44 +replace type_commodity= "High" if crop_code== 45 +replace type_commodity= "High" if crop_code== 46 +replace type_commodity= "High" if crop_code== 47 +replace type_commodity= "High" if crop_code== 48 +replace type_commodity= "High" if crop_code== 49 +replace type_commodity= "High" if crop_code== 50 +replace type_commodity= "High" if crop_code== 51 +replace type_commodity= "High" if crop_code== 52 +replace type_commodity= "High" if crop_code== 53 +replace type_commodity= "High" if crop_code== 54 +replace type_commodity= "High" if crop_code== 55 +replace type_commodity= "High" if crop_code== 56 +replace type_commodity= "High" if crop_code== 57 +replace type_commodity= "High" if crop_code== 58 +replace type_commodity= "High" if crop_code== 59 +replace type_commodity= "Low" if crop_code== 60 +replace type_commodity= "High" if crop_code== 61 +replace type_commodity= "Low" if crop_code== 62 +replace type_commodity= "High" if crop_code== 63 +replace type_commodity= "Low" if crop_code== 64 +replace type_commodity= "High" if crop_code== 65 +replace type_commodity= "High" if crop_code== 66 +replace type_commodity= "High" if crop_code== 67 +replace type_commodity= "High" if crop_code== 68 +replace type_commodity= "High" if crop_code== 69 +replace type_commodity= "High" if crop_code== 70 +replace type_commodity= "Out" if crop_code== 71 +replace type_commodity= "High" if crop_code== 72 +replace type_commodity= "Out" if crop_code== 73 +replace type_commodity= "Out" if crop_code== 74 +replace type_commodity= "High" if crop_code== 75 +replace type_commodity= "Out" if crop_code== 76 +replace type_commodity= "Out" if crop_code== 77 +replace type_commodity= "Out" if crop_code== 78 +replace type_commodity= "High" if crop_code== 79 +replace type_commodity= "High" if crop_code== 80 +replace type_commodity= "High" if crop_code== 81 +replace type_commodity= "High" if crop_code== 82 +replace type_commodity= "High" if crop_code== 83 +replace type_commodity= "High" if crop_code== 84 +replace type_commodity= "Out" if crop_code== 85 +replace type_commodity= "Out" if crop_code== 86 +replace type_commodity= "Out" if crop_code== 97 +replace type_commodity= "Low" if crop_code== 98 +replace type_commodity= "Out" if crop_code== 99 +replace type_commodity= "Out" if crop_code== 100 +replace type_commodity= "Out" if crop_code== 104 +replace type_commodity= "Out" if crop_code== 108 +replace type_commodity= "Out" if crop_code== 110 +replace type_commodity= "Out" if crop_code== 112 +replace type_commodity= "High" if crop_code== 113 +replace type_commodity= "Out" if crop_code== 114 +replace type_commodity= "High" if crop_code== 115 +replace type_commodity= "Out" if crop_code== 116 +replace type_commodity= "High" if crop_code== 117 +replace type_commodity= "High" if crop_code== 118 +replace type_commodity= "High" if crop_code== 119 +replace type_commodity= "Low" if crop_code== 120 +replace type_commodity= "Out" if crop_code== 121 +replace type_commodity= "Out" if crop_code== 122 +replace type_commodity= "High" if crop_code== 123 + +preserve +collapse (sum) value_crop_production value_crop_sales, by( hhid commodity) +ren value_crop_production value_pro +ren value_crop_sales value_sal +separate value_pro, by(commodity) +separate value_sal, by(commodity) +foreach s in pro sal { + ren value_`s'1 value_`s'_bana + ren value_`s'2 value_`s'_barl + ren value_`s'3 value_`s'_bean + ren value_`s'4 value_`s'_casav + ren value_`s'5 value_`s'_coff + ren value_`s'6 value_`s'_coton + ren value_`s'7 value_`s'_fruit + ren value_`s'8 value_`s'_gdnut + ren value_`s'9 value_`s'_maize + ren value_`s'10 value_`s'_mill + ren value_`s'11 value_`s'_oilc + ren value_`s'12 value_`s'_onio + ren value_`s'13 value_`s'_ocer + ren value_`s'14 value_`s'_onuts + ren value_`s'15 value_`s'_oths + ren value_`s'16 value_`s'_ortub + ren value_`s'17 value_`s'_pota + ren value_`s'18 value_`s'_sorg + ren value_`s'19 value_`s'_sybea + ren value_`s'20 value_`s'_spice + ren value_`s'21 value_`s'_suga + ren value_`s'22 value_`s'_spota + ren value_`s'23 value_`s'_teff + ren value_`s'24 value_`s'_vegs + ren value_`s'25 value_`s'_whea + ren value_`s'26 value_`s'_yam +} + + +foreach x of varlist value_pro* { + local l`x':var label `x' + local l`x'= subinstr("`l`x''","value_pro, commodity == ","Value of production, ",.) + lab var `x' "`l`x''" +} +foreach x of varlist value_sal* { + local l`x':var label `x' + local l`x'= subinstr("`l`x''","value_sal, commodity == ","Value of sales, ",.) + lab var `x' "`l`x''" +} + +qui recode value_* (.=0) +foreach x of varlist value_* { + local l`x':var label `x' +} +collapse (sum) value_*, by(hhid) +foreach x of varlist value_* { + lab var `x' "`l`x''" +} + +drop value_pro value_sal +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_grouped.dta", replace +restore + +*type of commodity +collapse (sum) value_crop_production value_crop_sales, by( hhid type_commodity) +ren value_crop_production value_pro +ren value_crop_sales value_sal +separate value_pro, by(type_commodity) +separate value_sal, by(type_commodity) +foreach s in pro sal { + ren value_`s'1 value_`s'_high + ren value_`s'2 value_`s'_low + /*DYA.10.30.2020*/ ren value_`s'3 value_`s'_other +} +foreach x of varlist value_pro* { + local l`x':var label `x' + local l`x'= subinstr("`l`x''","value_pro, type_commodity == ","Value of production, ",.) + lab var `x' "`l`x''" +} +foreach x of varlist value_sal* { + local l`x':var label `x' + local l`x'= subinstr("`l`x''","value_sal, type_commodity == ","Value of sales, ",.) + lab var `x' "`l`x''" +} + +qui recode value_* (.=0) +foreach x of varlist value_* { + local l`x':var label `x' +} + +qui recode value_* (.=0) +collapse (sum) value_*, by(hhid) +foreach x of varlist value_* { + lab var `x' "`l`x''" +} +drop value_pro value_sal +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_type_crop.dta", replace + + + +******************************************************************************** +*SHANNON DIVERSITY INDEX +******************************************************************************** +//KEF 7.19.21 / +*Bring in area planted +use "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan.dta", clear +preserve +collapse (sum) area_plan_hh=area_plan area_plan_female_hh=area_plan_female area_plan_male_hh=area_plan_male area_plan_mixed_hh=area_plan_mixed, by(hhid) +save "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan_shannon.dta", replace +restore +merge m:1 hhid using "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan_shannon.dta", nogen +recode area_plan_female area_plan_male area_plan_female_hh area_plan_male_hh area_plan_mixed area_plan_mixed_hh (0=.) +gen prop_plan = area_plan/area_plan_hh +gen prop_plan_female=area_plan_female/area_plan_female_hh +gen prop_plan_male=area_plan_male/area_plan_male_hh +gen prop_plan_mixed=area_plan_mixed/area_plan_mixed_hh +gen sdi_crop = prop_plan*ln(prop_plan) +gen sdi_crop_female = prop_plan_female*ln(prop_plan_female) +gen sdi_crop_male = prop_plan_male*ln(prop_plan_male) +gen sdi_crop_mixed = prop_plan_mixed*ln(prop_plan_mixed) +*tagging those that are missing all values +bysort hhid (sdi_crop_female) : gen allmissing_female = mi(sdi_crop_female[1]) +bysort hhid (sdi_crop_male) : gen allmissing_male = mi(sdi_crop_male[1]) +bysort hhid (sdi_crop_mixed) : gen allmissing_mixed = mi(sdi_crop_mixed[1]) +*Generating number of crops per household +bysort hhid crop_code : gen nvals_tot = _n==1 +gen nvals_female = nvals_tot if area_plan_female!=0 & area_plan_female!=. +gen nvals_male = nvals_tot if area_plan_male!=0 & area_plan_male!=. +gen nvals_mixed = nvals_tot if area_plan_mixed!=0 & area_plan_mixed!=. +collapse (sum) sdi=sdi_crop sdi_female=sdi_crop_female sdi_male=sdi_crop_male sdi_mixed=sdi_crop_mixed num_crops_hh=nvals_tot num_crops_female=nvals_female /// +num_crops_male=nvals_male num_crops_mixed=nvals_mixed (max) allmissing_female allmissing_male allmissing_mixed, by(hhid) +la var sdi "Shannon diversity index" +la var sdi_female "Shannon diversity index on female managed plots" +la var sdi_male "Shannon diversity index on male managed plots" +la var sdi_mixed "Shannon diversity index on mixed managed plots" +replace sdi_female=. if allmissing_female==1 +replace sdi_male=. if allmissing_male==1 +replace sdi_mixed=. if allmissing_mixed==1 +gen encs = exp(-sdi) +gen encs_female = exp(-sdi_female) +gen encs_male = exp(-sdi_male) +gen encs_mixed = exp(-sdi_mixed) +la var encs "Effective number of crop species per household" +la var encs_female "Effective number of crop species on female managed plots per household" +la var encs_male "Effective number of crop species on male managed plots per household" +la var encs_mixed "Effective number of crop species on mixed managed plots per household" +la var num_crops_hh "Number of crops grown by the household" +la var num_crops_female "Number of crops grown on female managed plots" +la var num_crops_male "Number of crops grown on male managed plots" +la var num_crops_mixed "Number of crops grown on mixed managed plots" +gen multiple_crops = (num_crops_hh>1 & num_crops_hh!=.) +la var multiple_crops "Household grows more than one crop" +save "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_shannon_diversity_index.dta", replace + + +******************************************************************************** +*CONSUMPTION +******************************************************************************** + +*BET 05.26.2021, updated 7/20/2021 +use "${Ethiopia_ESS_W4_temp_data}/cons_agg_w4.dta", clear +ren total_cons_ann total_cons +/* +/// CHECK BET 06.15.2021 there is no price index in wave 4, just an adj var for total consumption per AEQ, but also not clear whether it's only adjusting food prices or adjusting all. will back out using two methods +gen peraeq_cons = nom_totcons_aeq +gen price_index_hce = spat_totcons_aeq / nom_totcons_aeq +gen price_index_hce2 = (spat_totcons_aeq - ( nom_totcons_aeq - nom_foodcons_aeq))/ nom_foodcons_aeq // this is assuming that only food consumption is adjusted using index +* replace total_cons = total_cons * price_index_hce // Adjusting for price index // BET 05.26.2021 not seeing this in data +* replace peraeq_cons = peraeq_cons * price_index_hce // Adjusting for price index / BET 05.26.2021 not seeing this in data +*/ +gen peraeq_cons = spat_totcons_aeq +la var peraeq_cons "Household consumption per adult equivalent per year" +gen daily_peraeq_cons = peraeq_cons/365 +la var daily_peraeq_cons "Household consumption per adult equivalent per day" +gen percapita_cons = (total_cons / hh_size) +la var percapita_cons "Household consumption per household member per year" +gen daily_percap_cons = percapita_cons/365 +la var daily_percap_cons "Household consumption per household member per day" +keep household_id adulteq total_cons peraeq_cons daily_peraeq_cons percapita_cons daily_percap_cons +ren household_id hhid +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_consumption.dta", replace + + +******************************************************************************** +*HOUSEHOLD FOOD PROVISION* +******************************************************************************** +use "${Ethiopia_ESS_W4_temp_data}/sect8_hh_W4.dta", clear +*BET 05.26.2021 +/* +numlist "1/12" +forval k=1/12{ + local num: word `k' of `r(numlist)' + local alph: word `k' of `c(alpha)' + ren hh_s7q07_`alph' hh_s7q07_`num' +} +*/ +// BET 05.26.2021 14 months are asked about. taking last twelve months (july - june) +forval k=3/14 { + gen food_insecurity_`k'= (s8q07__`k'==1) +} + +egen months_food_insec = rowtotal(food_insecurity*) +*replacing those that report over 12 months of food insecurity +replace months_food_insec = 12 if months_food_insec>12 +lab var months_food_insec "Number of months of inadequate food provision" +keep household_id months_food_insec +save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_food_insecurity.dta", replace + + +******************************************************************************** +*HOUSEHOLD ASSETS* +******************************************************************************** +*Cannot calculate in this instrument - questionnaire doesn't ask value of HH assets + + +******************************************************************************** +*DISTANCE TO AGRO DEALERS* +******************************************************************************** +*Cannot calculate in this instrument + + +******************************************************************************** +*HOUSEHOLD VARIABLES +******************************************************************************** +global empty_vars "" +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_male_head.dta", clear +ren household_id hhid //ALT QUICK FIX +//drop pw_W4 +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhids.dta", nogen // all matched +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_hh_adulteq.dta", nogen keep(1 3) + +*Gross crop income (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_production.dta", nogen keep(1 3) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_crop_losses.dta", nogen keep(1 3) +recode value_crop_production crop_value_lost (.=0) + +* Production by group and type of crops (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_grouped.dta", nogen +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_type_crop.dta", nogen +recode value_pro* value_sal* (.=0) +*End DYA 9.13.2020 +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_cost_inputs.dta", nogen + +*Crop costs (NGA) +//Merge in summarized crop costs: +gen crop_production_expenses = cost_expli_hh +gen crop_income = value_crop_production - crop_production_expenses - crop_value_lost +lab var crop_production_expenses "Crop production expenditures (explicit)" +lab var crop_income "Net crop revenue (value of production minus crop expenses)" + +*top crop costs by area planted (NGA) +foreach c in $topcropname_area { + merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_inputs_`c'.dta", nogen + merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_`c'_monocrop_hh_area.dta",nogen +} + +foreach c in $topcropname_area { + recode `c'_monocrop (.=0) + //egen `c'_exp = rowtotal(val_anml_`c' val_mech_`c' val_labor_`c' val_herb_`c' val_inorg_`c' val_orgfert_`c' val_plotrent_`c' val_seeds_`c' val_transfert_`c' val_seedtrans_`c') //Need to be careful to avoid including val_harv + //lab var `c'_exp "Crop production expenditures (explicit) - Monocropped `c' plots only" + //la var `c'_monocrop_ha "Total `c' monocrop hectares planted - Household" + +*disaggregate by gender of plot manager (NGA) +foreach i in male female mixed hh { + egen `c'_exp_`i' = rowtotal(/*val_anml_`c'_`i' val_mech_`c'_`i'*/ val_labor_`c'_`i' /*val_herb_`c'_`i'*/ val_inorg_`c'_`i' /*val_orgfert_`c'_`i'*/ val_fieldrent_`c'_`i' val_seeds_`c'_`i' /*val_transfert_`c'_`i' val_seedtrans_`c'_`i'*/) //These are already narrowed to explicit costs + if strmatch("`i'", "hh") { + ren `c'_exp_`i' `c'_exp + lab var `c'_exp "Crop production expenditures (explicit) - Monocropped `c' plots only" + la var `c'_monocrop_ha "Total `c' monocrop hectares planted - Household" + } + else lab var `c'_exp_`i' "Crop production expenditures (explicit) - Monocropped `c' `i' managed plots" +} +replace `c'_exp = . if `c'_monocrop_ha==. // set to missing if the household does not have any monocropped maize plots +foreach i in male female mixed{ + replace `c'_exp_`i' = . if `c'_monocrop_ha_`i'==. + } +} +//drop rental_cost_land* cost_seed* value_fertilizer* cost_trans_fert* value_herbicide* value_pesticide* value_manure_purch* cost_trans_manure* +drop /*val_anml* val_mech*/ val_labor* /*val_herb*/ val_inorg* /*val_orgfert*/ val_fieldrent* val_seeds* /*val_transfert* val_seedtrans*/ // + +*Land rights (NGA) +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_rights_hh.dta", nogen keep(1 3) //ALT 03.07.24: Module missing, for follow up +//la var formal_land_rights_hh "Household has documentation of land rights (at least one plot) + +* Fish income (ETH) +gen fishing_income = . +gen w_share_fishing = . +global empty_vars $empty_vars *fishing_income* w_share_fishing fishing_hh + +*Livestock income (ETH +//ALT QUICK FIX +replace household_id = hhid if household_id=="" +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_sales.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_expenses.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_products.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_herd_characteristics.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_TLU_Coefficients.dta", nogen keep(1 3) +lab var sales_livestock_products "Value of sales of livestock products" +lab var value_livestock_products "Value of livestock products" +recode value_livestock_sales value_livestock_purchases value_milk_produced value_eggs_produced earnings_milk_products /* +*/ cost_breeding_livestock cost_fodder_livestock cost_vaccines_livestock cost_treatment_livestock cost_water_livestock tlu_today (.=0) +gen livestock_income = value_slaughtered + value_lvstck_sold - value_livestock_purchases /* +*/ + (value_milk_produced + value_eggs_produced + earnings_milk_products) /* +*/ - (cost_breeding_livestock + cost_fodder_livestock + cost_vaccines_livestock + cost_treatment_livestock + cost_water_livestock) +recode value_milk_produced value_eggs_produced (0=.) +lab var livestock_income "Net livestock income (value of production and consumption minus expenditures)" +gen livestock_expenses = cost_breeding_livestock + cost_fodder_livestock + cost_vaccines_livestock + cost_treatment_livestock + cost_water_livestock +gen ls_exp_vac = cost_vaccines_livestock + cost_treatment_livestock +lab var sales_livestock_products "Value of sales of livestock products" +lab var value_livestock_products "Value of livestock products" +lab var livestock_expenses "Total livestock expenses" +drop value_livestock_purchases earnings_milk_products cost_breeding_livestock cost_fodder_livestock cost_vaccines_livestock cost_treatment_livestock cost_water_livestock +gen animals_lost12months =0 +gen mean_12months=0 +la var animals_lost12months "Total number of livestock lost to disease" +la var mean_12months "Average number of livestock today and 1 year ago" +//gen any_imp_herd_all = . +foreach v in ls_exp_vac /*any_imp_herd*/ { +foreach i in lrum srum poultry { + gen `v'_`i' = . + } +} +//adding - starting list of missing variables - recode all of these to missing at end of HH level file +global empty_vars $empty_vars animals_lost12months mean_12months *ls_exp_vac_lrum* *ls_exp_vac_srum* *ls_exp_vac_poultry* /*any_imp_herd_*/ + +* Self employment income (NGA) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_self_employment_income.dta", nogen keep(1 3) +egen self_employment_income = rowtotal(/*profit_processed_crop_sold*/ annual_selfemp_profit) +recode self_employment_income (.=0) +lab var self_employment_income "Income from self-employment (business)" + +* Wage income (NGA) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wage_income.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_agwage_income.dta", nogen keep(1 3) +recode annual_salary annual_salary_agwage (.=0) +ren annual_salary nonagwage_income +ren annual_salary_agwage agwage_income + +*Off-farm hours (ETH) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_off_farm_hours.dta", nogen keep(1 3) + +*Other income (ETH) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_other_income.dta", nogen keep(1 3) +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_assistance_income.dta", nogen keep(1 3) +// JM 10.30.23: Add remmittances income +egen transfers_income = rowtotal (/*remittance_income*/ assistance_income) // JM 10.30.23: Do we need to create remmittance_income? +lab var transfers_income "Income from transfers including pension, remittances, and assisances)" +egen all_other_income = rowtotal (investment_income /*rental_income_buildings*/ /*other_income*/ /*rental_income_assets*/) // JM 10.30.23: Do we need to create the commented-out variables? +lab var all_other_income "Income from other revenue streams not captured elsewhere" + +* Farm size (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size.dta", nogen keep(1 3) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size_all.dta", nogen keep(1 3) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_farmsize_all_agland.dta", nogen keep(1 3) +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_size_total.dta", nogen +//ren area_meas_hectares land_size +recode land_size (.=0) /* If no farm, then no farm area */ +recode land_size (.=0) +recode farm_size_agland (.=0) +gen farm_size_0_0=farm_size_agland==0 +gen farm_size_0_1=farm_size_agland>0 & farm_size_agland<=1 +gen farm_size_1_2=farm_size_agland>1 & farm_size_agland<=2 +gen farm_size_2_4=farm_size_agland>2 & farm_size_agland<=4 +gen farm_size_4_more=farm_size_agland>4 +lab var farm_size_0_0 "1=Household has no farm" +lab var farm_size_0_1 "1=Household farm size > 0 Ha and <=1 Ha" +lab var farm_size_1_2 "1=Household farm size > 1 Ha and <=2 Ha" +lab var farm_size_2_4 "1=Household farm size > 2 Ha and <=4 Ha" +lab var farm_size_4_more "1=Household farm size > 4 Ha" + +*Labor (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_family_hired_labor.dta", nogen keep(1 3) +recode labor_hired labor_family (.=0) + +* Household size (NGA) +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hhsize.dta", nogen keep(1 3) + +*Rates of vaccine usage, improved seeds, etc. (NGA) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_vaccine.dta", nogen keep(1 3) +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fert_use.dta", nogen keep(1 3) +//merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_improvedseed_use.dta", nogen keep(1 3) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_input_use.dta", nogen keep(1 3) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_imprvseed_crop.dta", nogen keep(1 3) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_any_ext.dta", nogen keep(1 3) +* merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fin_serv.dta", nogen keep(1 3) //MGM 5.21.2024 - this file does not exist for ETH W4 and cannot be constructed! +ren use_imprv_seed imprv_seed_use //ALT 02.03.22: Should probably fix code to align this with other inputs. +ren use_hybrid_seed hybrid_seed_use +recode /*use_fin_serv**/ ext_reach* use_inorg_fert imprv_seed_use vac_animal (.=0) +replace vac_animal=. if tlu_today==0 +replace use_inorg_fert=. if farm_area==0 | farm_area==. // Area cultivated this year +recode ext_reach* (0 1=.) if (value_crop_production==0 & livestock_income==0 & farm_area==0 & farm_area==. & tlu_today==0) +replace imprv_seed_use=. if farm_area==. +gen use_fin_serv_bank = . +gen use_fin_serv_credit = . +gen use_fin_serv_insur = . +gen use_fin_serv_digital = . +gen use_fin_serv_others = . +gen use_fin_serv_all = . +global empty_vars $empty_vars use_fin_serv* + +* Milk productivity (ETH) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_milk_animals.dta", nogen keep(1 3) +gen liters_milk_produced= liters_per_cow*milk_animals +lab var liters_milk_produced "Total quantity (liters) of milk per year" +drop liters_per_cow +gen liters_per_largeruminant = . +gen liters_per_buffalo = . +global empty_vars $empty_vars *liters_per_largeruminant *liters_per_buffalo + +* Dairy costs (ETH) +//ALT QUICK FIX +merge 1:1 household_id using "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_lrum_expenses", nogen keep (1 3) +gen avg_cost_lrum = cost_lrum/mean_12months_lrum +gen costs_dairy = avg_cost_lrum*milk_animals +lab var avg_cost_lrum "Average cost per large ruminant" +lab var milk_animals "Number of large ruminants that were milked (household)" +lab var costs_dairy "Dairy production cost (explicit)" +gen costs_dairy_percow = . +lab var costs_dairy_percow "Dairy production cost (explicit) per cow" +drop avg_cost_lrum cost_lrum +gen share_imp_dairy = . +global empty_vars $empty_vars share_imp_dairy *costs_dairy_percow* + +* Egg productivity (NGA) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_eggs_animals.dta", nogen keep(1 3) +gen egg_poultry_year = eggs_total_year/hen_total +ren hen_total poultry_owned +lab var egg_poultry_year "average number of eggs per year per hen" + +*Costs of crop production per hectare (new) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_cropcosts.dta", nogen keep(1 3) + +*Rate of fertilizer application (new) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_fertilizer_application.dta", nogen keep(1 3) keepusing(fung* fert* pest* herb* ha_planted*) + +*Agricultural wage rate (new) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_ag_wage.dta", nogen keep(1 3) + +*Crop yields +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_yield_hh_crop_level.dta", nogen keep(1 3) + +*Total area planted and harvested accross all crops, plots, and seasons (new) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_area_planted_harvested_allcrops.dta", nogen keep(1 3) + +*Household diet (ETH) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_household_diet.dta", nogen keep(1 3) + +* Consumption (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_consumption.dta", nogen keep(1 3) + +*Household assets (Title from NGA, content from ETH) +gen value_assets = . +global empty_vars $empty_vars *value_assets* + +* Food insecurity (NGA) +* merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_food_insecurity.dta", nogen keep(1 3) +gen hhs_little = . +gen hhs_moderate = . +gen hhs_severe = . +gen hhs_total = . +global empty_vars $empty_vars hhs_* + +*Distance to agrodealer // cannot construct (NGA) +gen dist_agrodealer = . +global empty_vars $empty_vars *dist_agrodealer + +*Livestock health (Title from NGA, content from ETH) +gen disease_animal = . // JM 11.1.23: Added this line for *correct subpopulations* +gen lost_disease = . +foreach i in lrum srum poultry{ + gen disease_animal_`i' = . // JM 11.1.23: Added this line for *correct subpopulations* + gen lost_disease_`i' = . +} +global empty_vars $empty_vars lost_disease* + +*livestock feeding, water, and housing (Title from NGA) +//ALT QUICK FIX +merge 1:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_livestock_feed_water_house.dta", nogen keep(1 3) + +*Shannon Diversity index (NGA) +merge 1:1 hhid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_shannon_diversity_index.dta", nogen keep(1 3) + +*Farm Production (NGA) +recode value_crop_production value_livestock_products value_slaughtered value_lvstck_sold (.=0) +gen value_farm_production = value_crop_production + value_livestock_products + value_slaughtered + value_lvstck_sold +lab var value_farm_production "Total value of farm production (crops + livestock products)" +gen value_farm_prod_sold = value_crop_sales + sales_livestock_products + value_livestock_sales +lab var value_farm_prod_sold "Total value of farm production that is sold" +replace value_farm_prod_sold = 0 if value_farm_prod_sold==. & value_farm_production!=. + +* Agricultural households (NGA) +recode value_crop_production livestock_income farm_area tlu_today (.=0) +gen ag_hh = (value_crop_production!=0 | livestock_income!=0 | farm_area!=0 | tlu_today!=0) +lab var ag_hh "1= Household has some land cultivated, some livestock, some crop income, or some livestock income" + +*household with egg-producing animals (NGA) +gen egg_hh = (value_eggs_produced>0 & value_eggs_produced!=.) +lab var egg_hh "1=Household engaged in egg production" +*household engaged in dairy production (NGA) +gen dairy_hh = (value_milk_produced>0 & value_milk_produced!=.) +lab var dairy_hh "1= Household engaged in dairy production" + +*Households engaged in ag activities including working in paid ag jobs (NGA) +gen agactivities_hh =ag_hh==1 | (agwage_income!=0 & agwage_income!=.) +lab var agactivities_hh "1=Household has some land cultivated, livestock, crop income, livestock income, or ag wage income" + +*Creating crop households and livestock households +gen crop_hh = (value_crop_production!=0 | farm_area!=0) +lab var crop_hh "1= Household has some land cultivated or some crop income" +gen livestock_hh = (livestock_income!=0 | tlu_today!=0) +lab var livestock_hh "1= Household has some livestock or some livestock income" +recode fishing_income (.=0) +// gen fishing_hh = (fishing_income!=0) +// lab var fishing_hh "1= Household has some fishing income" + +/* +recode annual_selfemp_profit wage_income agwage_income transfer_income pension_income investment_income rental_income sales_income inheritance_income /* +*/ psnp_income assistance_income land_rental_income_upfront (.=0) +gen fish_trading_income = . +egen self_employment_income = rowtotal(annual_selfemp_profit fish_trading_income) +ren wage_income nonagwage_income +lab var self_employment_income "Income from self-employment (business)" +egen transfers_income = rowtotal (transfer_income pension_income assistance_income psnp_income) +lab var transfers_income "Income from transfers including pension, remittances, and assisances)" +egen all_other_income = rowtotal (investment_income rental_income sales_income land_rental_income_upfront inheritance_income ) +lab var all_other_income "Income from other revenue streams not captured elsewhere" +drop annual_selfemp_profit fish_trading_income transfer_income pension_income assistance_income psnp_income investment_income rental_income sales_income land_rental_income_upfront inheritance_income +*/ + +****getting correct subpopulations***** (ETH) +*Recoding missings to 0 for households growing crops +recode grew* (.=0) +*all rural households growing specific crops +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode value_harv_`cn' value_sold_`cn' kgs_harvest_`cn' total_planted_area_`cn' total_harv_area_`cn' `cn'_exp (.=0) if grew_`cn'==1 + recode value_harv_`cn' value_sold_`cn' kgs_harvest_`cn' total_planted_area_`cn' total_harv_area_`cn' `cn'_exp (nonmissing=.) if grew_`cn'==0 +} +*all rural households engaged in livestock production of a given species +foreach i in lrum srum poultry{ + recode ls_exp_vac_`i' disease_animal_`i' feed_grazing_`i' water_source_nat_`i' water_source_const_`i' water_source_cover_`i' lvstck_housed_`i' (nonmissing=.) if lvstck_holding_`i'==0 + recode ls_exp_vac_`i' disease_animal_`i' feed_grazing_`i' water_source_nat_`i' water_source_const_`i' water_source_cover_`i' lvstck_housed_`i'(.=0) if lvstck_holding_`i'==1 +} +*households engaged in crop production +recode cost_expli* value_crop_production value_crop_sales labor_hired labor_family farm_size_agland all_area_harvested all_area_planted encs num_crops_hh multiple_crops (.=0) if crop_hh==1 +recode cost_expli* value_crop_production value_crop_sales labor_hired labor_family farm_size_agland all_area_harvested all_area_planted encs num_crops_hh multiple_crops (nonmissing=.) if crop_hh==0 +*all rural households engaged in livestock production +recode animals_lost12months* mean_12months* livestock_expenses disease_animal feed_grazing water_source_nat water_source_const water_source_cover lvstck_housed (.=0) if livestock_hh==1 +recode animals_lost12months* mean_12months* livestock_expenses disease_animal feed_grazing water_source_nat water_source_const water_source_cover lvstck_housed (nonmissing=.) if livestock_hh==0 +*all rural households +recode /*DYA.10.26.2020*/ hrs_ag_activ hrs_wage_off_farm hrs_wage_on_farm hrs_unpaid_off_farm hrs_domest_fire_fuel hrs_off_farm hrs_on_farm hrs_domest_all hrs_other_all hrs_self_off_farm crop_income livestock_income self_employment_income nonagwage_income agwage_income transfers_income all_other_income (.=0) +*all rural households engaged in dairy production +recode costs_dairy liters_milk_produced value_milk_produced (.=0) if dairy_hh==1 +recode costs_dairy liters_milk_produced value_milk_produced (nonmissing=.) if dairy_hh==0 +*all rural households eith egg-producing animals +recode eggs_total_year value_eggs_produced (.=0) if egg_hh==1 +recode eggs_total_year value_eggs_produced (nonmissing=.) if egg_hh==0 +//drop value_harv* + +global gender "female male mixed" // (ETH) +global wins_var_top1 /* +*/ value_crop_production value_crop_sales value_harv* value_sold* kgs_harv* /*kgs_harv_mono*/ total_planted_area* total_harv_area* /* +*/ labor_hired labor_family /* //JM 11.1.23: Removed "w_labor_other" for consistency with NGA W4 +*/ animals_lost12months mean_12months lost_disease* /* +*/ liters_milk_produced costs_dairy /* +*/ eggs_total_year value_eggs_produced value_milk_produced /* +*/ /*DYA.10.26.2020*/ hrs_ag_activ hrs_wage_off_farm hrs_wage_on_farm hrs_unpaid_off_farm hrs_domest_fire_fuel hrs_off_farm hrs_on_farm hrs_domest_all hrs_other_all hrs_self_off_farm crop_production_expenses value_assets cost_expli_hh /* +*/ livestock_expenses ls_exp_vac* sales_livestock_products value_livestock_products value_livestock_sales /* +*/ value_farm_production value_farm_prod_sold value_pro* value_sal* + + + +*** Begin addressing outliers and estimating indicators that are ratios using winsorized values *** +global gender "female male mixed" +global wins_var_top1 /* +*/ cost_total_hh cost_expli_hh /* +*/ value_crop_production value_crop_sales value_harv* value_sold* kgs_harvest* total_planted_area* total_harv_area* /* +*/ labor_hired labor_family /*labor_other*/ /* +*/ animals_lost12months* mean_12months* lost_disease* /* +*/ liters_milk_produced costs_dairy eggs_total_year value_eggs_produced value_milk_produced /* +*/ /*DYA.10.26.2020*/ hrs_ag_activ hrs_wage_off_farm hrs_wage_on_farm hrs_unpaid_off_farm hrs_domest_fire_fuel hrs_off_farm hrs_on_farm hrs_domest_all hrs_other_all hrs_self_off_farm livestock_expenses ls_exp_vac* crop_production_expenses value_assets kgs_harv_mono* sales_livestock_products value_livestock_products value_livestock_sales /* +*/ value_farm_production value_farm_prod_sold value_pro* value_sal* + + +gen wage_paid_aglabor_mixed=. //create this just to make the loop work and delete after (ETH) +foreach v of varlist $wins_var_top1 { + _pctile `v' [aw=weight] , p($wins_upper_thres) + gen w_`v'=`v' + replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. + local l`v' : var lab `v' + lab var w_`v' "`l`v'' - Winzorized top 1%" +} + +global wins_var_top1_gender="" +foreach v in $topcropname_area { + global wins_var_top1_gender $wins_var_top1_gender `v'_exp +} +gen cost_total = cost_total_hh //JM 11.1.23: Added this line for consistency with NGA W4 +gen cost_expli = cost_expli_hh //JM 11.1.23: Added this line for consistency with NGA W4 +global wins_var_top1_gender $wins_var_top1_gender cost_total cost_expli fert_inorg_kg wage_paid_aglabor +foreach v of varlist $wins_var_top1_gender { + _pctile `v' [aw=weight] , p($wins_upper_thres) + gen w_`v'=`v' + replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. + local l`v' : var lab `v' + lab var w_`v' "`l`v'' - Winzorized top 1%" + *some variables are disaggreated by gender of plot manager. For these variables, we use the top 1% percentile to winsorize gender-disagregated variables + foreach g of global gender { + gen w_`v'_`g'=`v'_`g' + replace w_`v'_`g' = r(r1) if w_`v'_`g' > r(r1) & w_`v'_`g'!=. + local l`v'_`g' : var lab `v'_`g' + lab var w_`v'_`g' "`l`v'_`g'' - Winzorized top 1%" + } +} +global empty_vars $empty_vars w_lost_disease w_lost_disease_lrum w_lost_disease_srum w_lost_disease_poultry +drop *wage_paid_aglabor_mixed +*Generating labor_total as sum of winsorized labor_hired and labor_family +egen w_labor_total=rowtotal(w_labor_hired w_labor_family) //JM 11.1.23: Removed "w_labor_other" for consistency with NGA W4 +local llabor_total : var lab labor_total +lab var w_labor_total "`labor_total' - Winzorized top 1%" + +*Variables winsorized both at the top 1% and bottom 1% (ETH) +global wins_var_top1_bott1 /* +*/ farm_area farm_size_agland all_area_harvested all_area_planted ha_planted /* +*/ crop_income livestock_income fishing_income self_employment_income nonagwage_income agwage_income transfers_income all_other_income /* +*/ total_cons percapita_cons daily_percap_cons peraeq_cons daily_peraeq_cons /* +*/ *_monocrop_ha* dist_agrodealer + +foreach v of varlist $wins_var_top1_bott1 { + _pctile `v' [aw=weight] , p($wins_lower_thres $wins_upper_thres) + gen w_`v'=`v' + replace w_`v'= r(r1) if w_`v' < r(r1) & w_`v'!=. & w_`v'!=0 /* we want to keep actual zeros */ + replace w_`v'= r(r2) if w_`v' > r(r2) & w_`v'!=. + local l`v' : var lab `v' + lab var w_`v' "`l`v'' - Winzorized top and bottom 1%" + *some variables are disaggreated by gender of plot manager. For these variables, we use the top and bottom 1% percentile to winsorize gender-disagregated variables + if "`v'"=="ha_planted" { + foreach g of global gender { + gen w_`v'_`g'=`v'_`g' + replace w_`v'_`g'= r(r1) if w_`v'_`g' < r(r1) & w_`v'_`g'!=. & w_`v'_`g'!=0 /* we want to keep actual zeros */ + replace w_`v'_`g'= r(r2) if w_`v'_`g' > r(r2) & w_`v'_`g'!=. + local l`v'_`g' : var lab `v'_`g' + lab var w_`v'_`g' "`l`v'_`g'' - Winzorized top and bottom 1%" + } + } +} + +*area_harv and area_plan are also winsorized both at the top 1% and bottom 1% because we need to analyze at the crop level (ETH) +global allyield male female mixed inter inter_male inter_female inter_mixed pure pure_male pure_female pure_mixed +global wins_var_top1_bott1_2 area_harv area_plan harvest +foreach v of global wins_var_top1_bott1_2 { + foreach c of global topcropname_area { + _pctile `v'_`c' [aw=weight] , p($wins_lower_thres $wins_upper_thres) + gen w_`v'_`c'=`v'_`c' + replace w_`v'_`c' = r(r1) if w_`v'_`c' < r(r1) & w_`v'_`c'!=0 + replace w_`v'_`c' = r(r2) if (w_`v'_`c' > r(r2) & w_`v'_`c' !=.) + local l`v'_`c' : var lab `v'_`c' + lab var w_`v'_`c' "`l`v'_`c'' - Winzorized top and bottom 1%" + * now use pctile from area for all to trim gender/inter/pure area + foreach g of global allyield { + gen w_`v'_`g'_`c'=`v'_`g'_`c' + replace w_`v'_`g'_`c' = r(r1) if w_`v'_`g'_`c' < r(r1) & w_`v'_`g'_`c'!=0 + replace w_`v'_`g'_`c' = r(r2) if (w_`v'_`g'_`c' > r(r2) & w_`v'_`g'_`c' !=.) + local l`v'_`g'_`c' : var lab `v'_`g'_`c' + lab var w_`v'_`g'_`c' "`l`v'_`g'_`c'' - Winzorized top and bottom 1%" + + } + } +} + +*Estimate variables that are ratios then winsorize top 1% and bottom 1% of the ratios (do not replace 0 by the percentitles) +*generate yield and weights for yields using winsorized values (ETH) +*Yield by Area Planted +foreach c of global topcropname_area { + gen yield_pl_`c'=w_harvest_`c'/w_area_plan_`c' + lab var yield_pl_`c' "Yield by area planted of `c' (kgs/ha) (household)" + gen ar_pl_wgt_`c' = weight*w_area_plan_`c' + lab var ar_pl_wgt_`c' "Planted area-adjusted weight for `c' (household)" + foreach g of global allyield { + gen yield_pl_`g'_`c'=w_harvest_`g'_`c'/w_area_plan_`g'_`c' + lab var yield_pl_`g'_`c' "Yield by area planted of `c' - (kgs/ha) (`g')" + gen ar_pl_wgt_`g'_`c' = weight*w_area_plan_`g'_`c' + lab var ar_pl_wgt_`g'_`c' "Planted area-adjusted weight for `c' (`g')" + } +} + +*generate yield and weights for yields using winsorized values +*Yield by area harvested +foreach c of global topcropname_area { + gen yield_hv_`c'=w_harvest_`c'/w_area_harv_`c' + lab var yield_hv_`c' "Yield by area harvested of `c' (kgs/ha) (household)" + gen ar_h_wgt_`c' = weight*w_area_harv_`c' + lab var ar_h_wgt_`c' "Harvested area-adjusted weight for `c' (household)" + foreach g of global allyield { + gen yield_hv_`g'_`c'=w_harvest_`g'_`c'/w_area_harv_`g'_`c' + lab var yield_hv_`g'_`c' "Yield by area harvested of `c' - (kgs/ha) (`g')" + gen ar_h_wgt_`g'_`c' = weight*w_area_harv_`g'_`c' + lab var ar_h_wgt_`g'_`c' "Harvested area-adjusted weight for `c' (`g')" + } +} + +*generate inorg_fert_rate, costs_total_ha, and costs_expli_ha using winsorized values +gen inorg_fert_rate=w_fert_inorg_kg/w_ha_planted +gen cost_total_ha=w_cost_total/w_ha_planted // JM 11.1.23: Changed cost_total to cost_total_hh +gen cost_expli_ha=w_cost_expli/w_ha_planted +gen cost_explicit_hh_ha=w_cost_expli_hh/w_ha_planted +foreach g of global gender { + gen inorg_fert_rate_`g'=w_fert_inorg_kg_`g'/ w_ha_planted_`g' + gen cost_total_ha_`g'=w_cost_total_`g'/ w_ha_planted_`g' + gen cost_expli_ha_`g'=w_cost_expli_`g'/ w_ha_planted_`g' +} +lab var inorg_fert_rate "Rate of fertilizer application (kgs/ha) (household level)" +lab var inorg_fert_rate_male "Rate of fertilizer application (kgs/ha) (male-managed crops)" +lab var inorg_fert_rate_female "Rate of fertilizer application (kgs/ha) (female-managed crops)" +lab var inorg_fert_rate_mixed "Rate of fertilizer application (kgs/ha) (mixed-managed crops)" +lab var cost_total_ha "Explicit + implicit costs (per ha) of crop production (household level)" +lab var cost_total_ha_male "Explicit + implicit costs (per ha) of crop production (male-managed plots)" +lab var cost_total_ha_female "Explicit + implicit costs (per ha) of crop production (female-managed plots)" +lab var cost_total_ha_mixed "Explicit + implicit costs (per ha) of crop production (mixed-managed plots)" +lab var cost_expli_ha "Explicit costs (per ha) of crop production (household level)" +lab var cost_expli_ha_male "Explicit costs (per ha) of crop production (male-managed plots)" +lab var cost_expli_ha_female "Explicit costs (per ha) of crop production (female-managed plots)" +lab var cost_expli_ha_mixed "Explicit costs (per ha) of crop production (mixed-managed plots)" +lab var cost_explicit_hh_ha "Explicit costs (per ha) of crop production (household level)" + +*mortality rate (ETH) +global animal_species lrum srum camel equine poultry +foreach s of global animal_species { + gen mortality_rate_`s' = animals_lost12months_`s'/mean_12months_`s' + lab var mortality_rate_`s' "Mortality rate - `s'" +} + +*Generating crop expenses by hectare for top crops (ETH) +forvalues k=1/$nb_topcrops { + local cn: word `k' of $topcropname_area + local cnfull: word `k' of $topcropname_full + gen `cn'_exp_ha = w_`cn'_exp / w_`cn'_monocrop_ha + la var `cn'_exp_ha "Costs per hectare - Monocropped `cnfull' plots" + foreach g of global gender { + gen `cn'_exp_ha_`g' = w_`cn'_exp_`g'/w_`cn'_monocrop_ha_`g' + local l`cn': var lab `cn'_exp_ha + la var `cn'_exp_ha_`g' "`l`cn'' - `g' managed plots" + } +} + +*Hours per capita using winsorized version off_farm_hours (ETH) +foreach x in ag_activ wage_off_farm wage_on_farm unpaid_off_farm domest_fire_fuel off_farm on_farm domest_all other_all { + local l`v':var label hrs_`x' + gen hrs_`x'_pc_all = hrs_`x'/member_count + lab var hrs_`x'_pc_all "Per capital (all) `l`v''" + gen hrs_`x'_pc_any = hrs_`x'/nworker_`x' + lab var hrs_`x'_pc_any "Per capital (only worker) `l`v''" +} + +*generating total crop production costs per hectare (ETH) +gen cost_expli_hh_ha = w_cost_expli_hh/w_ha_planted +lab var cost_expli_hh_ha "Explicit costs (per ha) of crop production (household level)" + +*land and labor productivity (ETH) +gen land_productivity = w_value_crop_production/w_farm_area +gen labor_productivity = w_value_crop_production/w_labor_total +lab var land_productivity "Land productivity (value production per ha cultivated)" +lab var labor_productivity "Labor productivity (value production per labor-day)" + +*Milk productivity (ETH) +gen liters_per_cow = w_liters_milk_produced/milk_animals +lab var liters_per_cow "average quantity (liters) per day (household) - cow" +la var liters_per_largeruminant "Average quantity (liters) per year (household)" // JM 11.1.23: Added for consistency with NGA W4 code. +global empty_vars $empty_vars liters_per_largeruminant // JM 11.1.23: Added for consistency with NGA W4 code. + +*Calculate proportion of crop value sold using winsorized values of value_crop_sales and value_crop_production (ETH) +gen w_proportion_cropvalue_sold = w_value_crop_sales / w_value_crop_production +replace w_proportion_cropvalue_sold = 1 if w_proportion_cropvalue_sold>1 & w_proportion_cropvalue_sold!=. +lab var w_proportion_cropvalue_sold "Proportion of crop value produced (winsorized) that has been sold" + +*livestock value sold (ETH) +gen w_share_livestock_prod_sold = w_sales_livestock_products / w_value_livestock_products +replace w_share_livestock_prod_sold = 1 if w_share_livestock_prod_sold>1 & w_share_livestock_prod_sold!=. +lab var w_share_livestock_prod_sold "Percent of production of livestock products (winsorized) that is sold" + +*Propotion of farm production sold (ETH) +gen w_prop_farm_prod_sold = w_value_farm_prod_sold / w_value_farm_production +replace w_prop_farm_prod_sold = 1 if w_prop_farm_prod_sold>1 & w_prop_farm_prod_sold!=. +lab var w_prop_farm_prod_sold "Proportion of farm production (winsorized) that has been sold" + +*Unit cost of production (ETH) +*top crops +forvalues k=1/$nb_topcrops { + local cn: word `k' of $topcropname_area + local cnfull: word `k' of $topcropname_full + gen `cn'_exp_kg = w_`cn'_exp / w_kgs_harv_mono_`cn' + la var `cn'_exp_kg "Costs per kilogram produced - `cnfull' monocropped plots" + foreach g of global gender { + gen `cn'_exp_kg_`g'= w_`cn'_exp_`g'/w_kgs_harv_mono_`cn'_`g' + local l`cn': var lab `cn'_exp_kg + la var `cn'_exp_kg_`g' "`l`cn'' - `g' mananged plots" + } +} + +*dairy (NGA) +gen cost_per_lit_milk = w_costs_dairy/w_liters_milk_produced +lab var cost_per_lit_milk "dairy production cost per liter" +global empty_vars $empty_vars cost_per_lit_milk + +*****getting correct subpopulations*** (ETH) +*all rural housseholds engaged in crop production (ETH) +recode inorg_fert_rate* cost_total_ha* cost_expli_ha* cost_expli_hh_ha land_productivity labor_productivity /* +*/ encs* num_crops* multiple_crops (.=0) if crop_hh==1 +recode inorg_fert_rate* cost_total_ha* cost_expli_ha* cost_expli_hh_ha land_productivity labor_productivity /* +*/ encs* num_crops* multiple_crops (nonmissing=.) if crop_hh==0 + +*all rural households engaged in livestcok production of a given species (ETH) +foreach i in lrum srum poultry{ + recode mortality_rate_`i' (nonmissing=.) if lvstck_holding_`i'==0 + recode mortality_rate_`i' (.=0) if lvstck_holding_`i'==1 +} +*all rural households (ETH) +recode /*DYA.10.26.2020*/ hrs_*_pc_all (.=0) +*households engaged in monocropped production of specific crops +forvalues k=1/$nb_topcrops { + local cn: word `k' of $topcropname_area + recode `cn'_exp `cn'_exp_ha `cn'_exp_kg (.=0) if `cn'_monocrop==1 + recode `cn'_exp `cn'_exp_ha `cn'_exp_kg (nonmissing=.) if `cn'_monocrop==0 +} +*all rural households growing specific crops (ETH) +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode yield_pl_`cn' (.=0) if grew_`cn'==1 + recode yield_pl_`cn' (nonmissing=.) if grew_`cn'==0 +} +*all rural households harvesting specific crops (ETH) +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode yield_hv_`cn' (.=0) if harvested_`cn'==1 + recode yield_hv_`cn' (nonmissing=.) if harvested_`cn'==0 +} + +*households growing specific crops that have also purestand plots of that crop (ETH) +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode yield_pl_pure_`cn' (.=0) if grew_`cn'==1 & w_area_plan_pure_`cn'!=. + recode yield_pl_pure_`cn' (nonmissing=.) if grew_`cn'==0 | w_area_plan_pure_`cn'==. +} +*all rural households harvesting specific crops (in the long rainy season) that also have purestand plots (ETH) +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode yield_hv_pure_`cn' (.=0) if harvested_`cn'==1 & w_area_plan_pure_`cn'!=. + recode yield_hv_pure_`cn' (nonmissing=.) if harvested_`cn'==0 | w_area_plan_pure_`cn'==. +} + +*households engaged in dairy production (ETH) +recode cost_per_lit_milk liters_per_cow (.=0) if dairy_hh==1 +recode cost_per_lit_milk liters_per_cow (nonmissing=.) if dairy_hh==0 +*households with egg-producing animals (ETH) +recode egg_poultry_year (.=0) if egg_hh==1 +recode egg_poultry_year (nonmissing=.) if egg_hh==0 + +*now winsorize ratios only at top 1% (ETH) +global wins_var_ratios_top1 inorg_fert_rate cost_total_ha cost_expli_ha cost_expli_hh_ha /* +*/ land_productivity labor_productivity /* +*/ mortality_rate* liters_per_largeruminant liters_per_cow liters_per_buffalo egg_poultry_year costs_dairy_percow /* +*/ /*DYA.10.26.2020*/ hrs_*_pc_all hrs_*_pc_any cost_per_lit_milk + +foreach v of varlist $wins_var_ratios_top1 { + _pctile `v' [aw=weight] , p($wins_upper_thres) + gen w_`v'=`v' + replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. + local l`v' : var lab `v' + lab var w_`v' "`l`v'' - Winzorized top 1%" + *some variables are disaggreated by gender of plot manager. For these variables, we use the top 1% percentile to winsorize gender-disagregated variables + if "`v'" =="inorg_fert_rate" | "`v'" =="cost_total_ha" | "`v'" =="cost_expli_ha" { + foreach g of global gender { + gen w_`v'_`g'=`v'_`g' + replace w_`v'_`g' = r(r1) if w_`v'_`g' > r(r1) & w_`v'_`g'!=. + local l`v'_`g' : var lab `v'_`g' + lab var w_`v'_`g' "`l`v'_`g'' - Winzorized top 1%" + } + } +} + +*Winsorizing top crop ratios (ETH) +foreach v of global topcropname_area { + *first winsorizing costs per hectare + _pctile `v'_exp_ha [aw=weight] , p($wins_upper_thres) + gen w_`v'_exp_ha = `v'_exp_ha + replace w_`v'_exp_ha = r(r1) if w_`v'_exp_ha > r(r1) & w_`v'_exp_ha!=. + local l`v'_exp_ha : var lab `v'_exp_ha + lab var w_`v'_exp_ha "`l`v'_exp_ha' - Winzorized top 1%" + *now by gender using the same method as above + foreach g of global gender { + gen w_`v'_exp_ha_`g'= `v'_exp_ha_`g' + replace w_`v'_exp_ha_`g' = r(r1) if w_`v'_exp_ha_`g' > r(r1) & w_`v'_exp_ha_`g'!=. + local l`v'_exp_ha_`g' : var lab `v'_exp_ha_`g' + lab var w_`v'_exp_ha_`g' "`l`v'_exp_ha_`g'' - winsorized top 1%" + } + *winsorizing cost per kilogram + _pctile `v'_exp_kg [aw=weight] , p($wins_upper_thres) + gen w_`v'_exp_kg=`v'_exp_kg + replace w_`v'_exp_kg = r(r1) if w_`v'_exp_kg > r(r1) & w_`v'_exp_kg!=. + local l`v'_exp_kg : var lab `v'_exp_kg + lab var w_`v'_exp_kg "`l`v'_exp_kg' - Winzorized top 1%" + *now by gender using the same method as above + foreach g of global gender { + gen w_`v'_exp_kg_`g'= `v'_exp_kg_`g' + replace w_`v'_exp_kg_`g' = r(r1) if w_`v'_exp_kg_`g' > r(r1) & w_`v'_exp_kg_`g'!=. + local l`v'_exp_kg_`g' : var lab `v'_exp_kg_`g' + lab var w_`v'_exp_kg_`g' "`l`v'_exp_kg_`g'' - winsorized top 1%" + } +} + + +*now winsorize ratio only at top 1% - yield (ETH) +foreach c of global topcropname_area { + foreach i in yield_pl yield_hv{ + _pctile `i'_`c' [aw=weight] , p($wins_upper_thres) + gen w_`i'_`c'=`i'_`c' + replace w_`i'_`c' = r(r1) if w_`i'_`c' > r(r1) & w_`i'_`c'!=. + local w_`i'_`c' : var lab `i'_`c' + lab var w_`i'_`c' "`w_`i'_`c'' - Winzorized top 1%" + foreach g of global allyield { + gen w_`i'_`g'_`c'= `i'_`g'_`c' + replace w_`i'_`g'_`c' = r(r1) if w_`i'_`g'_`c' > r(r1) & w_`i'_`g'_`c'!=. + local w_`i'_`g'_`c' : var lab `i'_`g'_`c' + lab var w_`i'_`g'_`c' "`w_`i'_`g'_`c'' - Winzorized top 1%" + } + } +} + +*Create final income variables using un_winzorized and winzorized values (ETH) +egen total_income = rowtotal(crop_income livestock_income self_employment_income nonagwage_income agwage_income transfers_income all_other_income) +egen nonfarm_income = rowtotal(self_employment_income nonagwage_income transfers_income all_other_income) +egen farm_income = rowtotal(crop_income livestock_income agwage_income) +lab var nonfarm_income "Nonfarm income (excludes ag wages)" +gen percapita_income = total_income/hh_members +lab var total_income "Total household income" +lab var percapita_income "Household incom per hh member per year" +lab var farm_income "Farm income" +egen w_total_income = rowtotal(w_crop_income w_livestock_income w_self_employment_income w_nonagwage_income w_agwage_income w_transfers_income w_all_other_income) +egen w_nonfarm_income = rowtotal(w_self_employment_income w_nonagwage_income w_transfers_income w_all_other_income) +egen w_farm_income = rowtotal(w_crop_income w_livestock_income w_agwage_income) +lab var w_nonfarm_income "Nonfarm income (excludes ag wages) - Winzorized top 1%" +lab var w_farm_income "Farm income - Winzorized top 1%" +gen w_percapita_income = w_total_income/hh_members +lab var w_total_income "Total household income - Winzorized top 1%" +lab var w_percapita_income "Household income per hh member per year - Winzorized top 1%" +global income_vars crop livestock self_employment nonagwage agwage transfers all_other +foreach p of global income_vars { + gen `p'_income_s = `p'_income + replace `p'_income_s = 0 if `p'_income_s < 0 + gen w_`p'_income_s = w_`p'_income + replace w_`p'_income_s = 0 if w_`p'_income_s < 0 +} +egen w_total_income_s = rowtotal(w_crop_income_s w_livestock_income_s w_self_employment_income_s w_nonagwage_income_s w_agwage_income_s w_transfers_income_s w_all_other_income_s) +foreach p of global income_vars { + gen w_share_`p' = w_`p'_income_s / w_total_income_s + lab var w_share_`p' "Share of household (winsorized) income from `p'_income" +} +egen w_nonfarm_income_s = rowtotal(w_self_employment_income_s w_nonagwage_income_s w_transfers_income_s w_all_other_income_s) +gen w_share_nonfarm = w_nonfarm_income_s / w_total_income_s +lab var w_share_nonfarm "Share of household income (winsorized) from nonfarm sources" +foreach p of global income_vars { + drop `p'_income_s w_`p'_income_s +} +drop w_total_income_s w_nonfarm_income_s + +***getting correct subpopulations +*all rural households (ETH not in NGA) +//note that consumption indicators are not included because there is missing consumption data and we do not consider 0 values for consumption to be valid +recode w_total_income w_percapita_income w_crop_income w_livestock_income /*w_fishing_income*/ w_nonagwage_income w_agwage_income w_self_employment_income w_transfers_income w_all_other_income /* +*/ w_share_crop w_share_livestock w_share_nonagwage w_share_agwage w_share_self_employment w_share_transfers w_share_all_other w_share_nonfarm /* +*/ use_fin_serv* use_inorg_fert imprv_seed_use /* +*/ /*formal_land_rights_hh*/ /*DYA.10.26.2020*/ *_hrs_*_pc_all /*months_food_insec*/ /* +*/ lvstck_holding_tlu lvstck_holding_all lvstck_holding_lrum lvstck_holding_srum lvstck_holding_poultry (.=0) if rural==1 + +*all rural households engaged in livestock production (ETH) +recode vac_animal w_share_livestock_prod_sold livestock_expenses w_ls_exp_vac any_imp_herd_all (. = 0) if livestock_hh==1 +recode vac_animal w_share_livestock_prod_sold livestock_expenses w_ls_exp_vac any_imp_herd_all (nonmissing = .) if livestock_hh==0 + +*all rural households engaged in livestcok production of a given species +foreach i in lrum srum poultry{ + recode vac_animal_`i' any_imp_herd_`i' w_ls_exp_vac_`i' (nonmissing=.) if lvstck_holding_`i'==0 + recode vac_animal_`i' any_imp_herd_`i' w_ls_exp_vac_`i' (.=0) if lvstck_holding_`i'==1 +} + +*households engaged in crop production +recode w_proportion_cropvalue_sold w_farm_size_agland w_labor_family w_labor_hired /* +*/ imprv_seed_use use_inorg_fert /*w_dist_agrodealer*/ w_labor_productivity w_land_productivity /* +*/ w_inorg_fert_rate w_cost_expli_hh w_cost_expli_hh_ha w_cost_expli_ha w_cost_total_ha /* +*/ w_value_crop_production w_value_crop_sales w_all_area_planted w_all_area_harvested (.=0) if crop_hh==1 +recode w_proportion_cropvalue_sold w_farm_size_agland w_labor_family w_labor_hired /* +*/ imprv_seed_use use_inorg_fert /*w_dist_agrodealer*/ w_labor_productivity w_land_productivity /* +*/ w_inorg_fert_rate w_cost_expli_hh w_cost_expli_hh_ha w_cost_expli_ha w_cost_total_ha /* +*/ w_value_crop_production w_value_crop_sales w_all_area_planted w_all_area_harvested (nonmissing= . ) if crop_hh==0 + +*hh engaged in crop or livestock production (ETH) +gen ext_reach_unspecified=0 // JM 11.1.23: This is not in NGA +recode ext_reach* (.=0) if (crop_hh==1 | livestock_hh==1) +recode ext_reach* (nonmissing=.) if crop_hh==0 & livestock_hh==0 +lab var ext_reach_unspecified "1 = Household reached by extensition services - unspecified sources" + +*all rural households growing specific crops +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode imprv_seed_`cn' hybrid_seed_`cn' w_yield_pl_`cn' /* + */ w_value_harv_`cn' w_value_sold_`cn' w_kgs_harvest_`cn' w_total_planted_area_`cn' w_total_harv_area_`cn' (.=0) if grew_`cn'==1 + recode imprv_seed_`cn' hybrid_seed_`cn' w_yield_pl_`cn' /* + */ w_value_harv_`cn' w_value_sold_`cn' w_kgs_harvest_`cn' w_total_planted_area_`cn' w_total_harv_area_`cn' (nonmissing=.) if grew_`cn'==0 +} +*all rural households that harvested specific crops +forvalues k=1(1)$nb_topcrops { + local cn: word `k' of $topcropname_area + recode w_yield_hv_`cn' (.=0) if harvested_`cn'==1 + recode w_yield_hv_`cn' (nonmissing=.) if harvested_`cn'==0 +} + +*households engaged in monocropped production of specific crops +forvalues k=1/$nb_topcrops { + local cn: word `k' of $topcropname_area + recode w_`cn'_exp w_`cn'_exp_ha w_`cn'_exp_kg (.=0) if `cn'_monocrop==1 + recode w_`cn'_exp w_`cn'_exp_ha w_`cn'_exp_kg (nonmissing=.) if `cn'_monocrop==0 +} + +*all rural households engaged in dairy production (ETH) +recode costs_dairy liters_milk_produced w_value_milk_produced (.=0) if dairy_hh==1 +recode costs_dairy liters_milk_produced w_value_milk_produced (nonmissing=.) if dairy_hh==0 +*all rural households eith egg-producing animals (ETH) +recode w_eggs_total_year w_value_eggs_produced (.=0) if egg_hh==1 +recode w_eggs_total_year w_value_eggs_produced (nonmissing=.) if egg_hh==0 + +*Identify smallholder farmers (RULIS definition) (NGA) +global small_farmer_vars land_size tlu_today total_income +foreach p of global small_farmer_vars { + gen `p'_aghh = `p' if ag_hh==1 + _pctile `p'_aghh [aw=weight] , p(40) + gen small_`p' = (`p' <= r(r1)) + replace small_`p' = . if ag_hh!=1 +} +gen small_farm_household = (small_land_size==1 & small_tlu_today==1 & small_total_income==1) +replace small_farm_household = . if ag_hh != 1 +sum small_farm_household if ag_hh==1 +drop land_size_aghh small_land_size tlu_today_aghh small_tlu_today total_income_aghh small_total_income +lab var small_farm_household "1= HH is in bottom 40th percentiles of land size, TLU, and total revenue" + +*create different weights (ETH) +gen w_labor_weight=weight*w_labor_total +lab var w_labor_weight "labor-adjusted household weights" +gen w_land_weight=weight*w_farm_area +lab var w_land_weight "land-adjusted household weights" +gen w_aglabor_weight_all=w_labor_hired*weight +lab var w_aglabor_weight_all "Hired labor-adjusted household weights" +gen w_aglabor_weight_female=. // cannot create in this instrument +lab var w_aglabor_weight_female "Hired labor-adjusted household weights -female workers" +gen w_aglabor_weight_male=. // cannot create in this instrument +lab var w_aglabor_weight_male "Hired labor-adjusted household weights -male workers" +gen weight_milk=milk_animals*weight +gen weight_egg=poultry_owned*weight +*generate area weights for monocropped plots +foreach cn in $topcropname_area { + gen ar_pl_mono_wgt_`cn'_all = weight*`cn'_monocrop_ha + gen kgs_harv_wgt_`cn'_all = weight*kgs_harv_mono_`cn' + foreach g in male female mixed { + gen ar_pl_mono_wgt_`cn'_`g' = weight*`cn'_monocrop_ha_`g' + gen kgs_harv_wgt_`cn'_`g' = weight*kgs_harv_mono_`cn'_`g' + } +} +gen w_ha_planted_all = ha_planted +foreach g in all female male mixed { + gen area_weight_`g'=weight*w_ha_planted_`g' } +gen w_ha_planted_weight=w_ha_planted_all*weight +drop w_ha_planted_all +gen individual_weight=hh_members*weight +gen adulteq_weight=adulteq*weight -qui recode value_* (.=0) -foreach x of varlist value_* { - local l`x':var label `x' -} -qui recode value_* (.=0) -collapse (sum) value_*, by(household_id) -foreach x of varlist value_* { - lab var `x' "`l`x''" -} -drop value_pro value_sal -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh_crop_values_production_type_crop.dta", replace -*End BET 07.19.2021 +*Rural poverty headcount ratio (ETH) +*First, we convert $1.90/day to local currency in 2011 using https://data.worldbank.org/indicator/PA.NUS.PRVT.PP?end=2011&locations=TZ&start=1990 + // 1.90 * 5.439 = 10.3341 +*NOTE: this is using the "Private Consumption, PPP" conversion factor because that's what we have been using. +* This can be changed this to the "GDP, PPP" if we change the rest of the conversion factors. +*The global poverty line of $1.90/day is set by the World Bank +*http://www.worldbank.org/en/topic/poverty/brief/global-poverty-line-faq +*Second, we inflate the local currency to the year that this survey was carried out using the CPI inflation rate using https://data.worldbank.org/indicator/FP.CPI.TOTL?end=2017&locations=TZ&start=2003 + // 1+(226.759 - 133.25)/ 133.25 = 1.7017561 + // 10.3341* 1.7017561 = 17.586118 ETB +*NOTE: if the survey was carried out over multiple years we use the last year +*This is the poverty line at the local currency in the year the survey was carried out +gen poverty_under_1_9 = (daily_percap_cons<17.586118) +la var poverty_under_1_9 "Household has a percapita conumption of under $1.90 in 2011 $ PPP)" -******************************************************************************** -*SHANNON DIVERSITY INDEX -******************************************************************************** -//KEF 7.19.21 / -*Bring in area planted -use "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan_SDI.dta", clear -*generating area planted of each crop as a proportion of the total area -preserve -collapse (sum) area_plan_hh=area_plan area_plan_female_hh=area_plan_female area_plan_male_hh=area_plan_male area_plan_mixed_hh=area_plan_mixed, by(household_id) -save "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan_shannon.dta", replace -restore -merge m:1 household_id using "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_hh_crop_area_plan_shannon.dta", nogen -recode area_plan_female area_plan_male area_plan_female_hh area_plan_male_hh area_plan_mixed area_plan_mixed_hh (0=.) -gen prop_plan = area_plan/area_plan_hh -gen prop_plan_female=area_plan_female/area_plan_female_hh -gen prop_plan_male=area_plan_male/area_plan_male_hh -gen prop_plan_mixed=area_plan_mixed/area_plan_mixed_hh -gen sdi_crop = prop_plan*ln(prop_plan) -gen sdi_crop_female = prop_plan_female*ln(prop_plan_female) -gen sdi_crop_male = prop_plan_male*ln(prop_plan_male) -gen sdi_crop_mixed = prop_plan_mixed*ln(prop_plan_mixed) -*tagging those that are missing all values -bysort household_id (sdi_crop_female) : gen allmissing_female = mi(sdi_crop_female[1]) -bysort household_id (sdi_crop_male) : gen allmissing_male = mi(sdi_crop_male[1]) -bysort household_id (sdi_crop_mixed) : gen allmissing_mixed = mi(sdi_crop_mixed[1]) -*Generating number of crops per household -bysort household_id crop_code : gen nvals_tot = _n==1 -gen nvals_female = nvals_tot if area_plan_female!=0 & area_plan_female!=. -gen nvals_male = nvals_tot if area_plan_male!=0 & area_plan_male!=. -gen nvals_mixed = nvals_tot if area_plan_mixed!=0 & area_plan_mixed!=. -collapse (sum) sdi=sdi_crop sdi_female=sdi_crop_female sdi_male=sdi_crop_male sdi_mixed=sdi_crop_mixed num_crops_hh=nvals_tot num_crops_female=nvals_female /// -num_crops_male=nvals_male num_crops_mixed=nvals_mixed (max) allmissing_female allmissing_male allmissing_mixed, by(household_id) -la var sdi "Shannon diversity index" -la var sdi_female "Shannon diversity index on female managed plots" -la var sdi_male "Shannon diversity index on male managed plots" -la var sdi_mixed "Shannon diversity index on mixed managed plots" -replace sdi_female=. if allmissing_female==1 -replace sdi_male=. if allmissing_male==1 -replace sdi_mixed=. if allmissing_mixed==1 -gen encs = exp(-sdi) -gen encs_female = exp(-sdi_female) -gen encs_male = exp(-sdi_male) -gen encs_mixed = exp(-sdi_mixed) -la var encs "Effective number of crop species per household" -la var encs_female "Effective number of crop species on female managed plots per household" -la var encs_male "Effective number of crop species on male managed plots per household" -la var encs_mixed "Effective number of crop species on mixed managed plots per household" -la var num_crops_hh "Number of crops grown by the household" -la var num_crops_female "Number of crops grown on female managed plots" -la var num_crops_male "Number of crops grown on male managed plots" -la var num_crops_mixed "Number of crops grown on mixed managed plots" -gen multiple_crops = (num_crops_hh>1 & num_crops_hh!=.) -la var multiple_crops "Household grows more than one crop" -save "$Ethiopia_ESS_W4_created_data/Ethiopia_ESS_W4_shannon_diversity_index.dta", replace +*average consumption expenditure of the bottom 40% of the rural consumption expenditure distribution +*By per capita consumption (ETH) +_pctile w_daily_percap_cons [aw=individual_weight] if rural==1, p(40) +gen bottom_40_percap = 0 +replace bottom_40_percap = 1 if r(r1) > w_daily_percap_cons & rural==1 +*By peraeq consumption (ETH) +_pctile w_daily_peraeq_cons [aw=adulteq_weight] if rural==1, p(40) +gen bottom_40_peraeq = 0 +replace bottom_40_peraeq = 1 if r(r1) > w_daily_peraeq_cons & rural==1 -******************************************************************************** -*CONSUMPTION -******************************************************************************** +****Currency Conversion Factors*** (ETH) +gen ccf_loc = 1 +lab var ccf_loc "currency conversion factor - 2016 $ETB" +gen ccf_usd = 1 / $Ethiopia_ESS_W4_exchange_rate +lab var ccf_usd "currency conversion factor - 2016 $USD" +gen ccf_1ppp = 1 / $Ethiopia_ESS_W4_cons_ppp_dollar +lab var ccf_1ppp "currency conversion factor - 2016 $Private Consumption PPP" +gen ccf_2ppp = 1 / $Ethiopia_ESS_W4_gdp_ppp_dollar +lab var ccf_2ppp "currency conversion factor - 2016 $GDP PPP" -*BET 05.26.2021, updated 7/20/2021 -use "${Ethiopia_ESS_W4_raw_data}/Consumption Aggregate/cons_agg_W4.dta", clear -ren total_cons_ann total_cons -/* -/// CHECK BET 06.15.2021 there is no price index in wave 4, just an adj var for total consumption per AEQ, but also not clear whether it's only adjusting food prices or adjusting all. will back out using two methods -gen peraeq_cons = nom_totcons_aeq -gen price_index_hce = spat_totcons_aeq / nom_totcons_aeq -gen price_index_hce2 = (spat_totcons_aeq - ( nom_totcons_aeq - nom_foodcons_aeq))/ nom_foodcons_aeq // this is assuming that only food consumption is adjusted using index -* replace total_cons = total_cons * price_index_hce // Adjusting for price index // BET 05.26.2021 not seeing this in data -* replace peraeq_cons = peraeq_cons * price_index_hce // Adjusting for price index / BET 05.26.2021 not seeing this in data -*/ -gen peraeq_cons = spat_totcons_aeq -la var peraeq_cons "Household consumption per adult equivalent per year" -gen daily_peraeq_cons = peraeq_cons/365 -la var daily_peraeq_cons "Household consumption per adult equivalent per day" -gen percapita_cons = (total_cons / hh_size) -la var percapita_cons "Household consumption per household member per year" -gen daily_percap_cons = percapita_cons/365 -la var daily_percap_cons "Household consumption per household member per day" -keep household_id adulteq total_cons peraeq_cons daily_peraeq_cons percapita_cons daily_percap_cons -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_consumption.dta", replace +*Cleaning up output to get below 5,000 variables +*dropping unnecessary variables and recoding to missing any variables that cannot be created in this instrument +drop harvest_* w_harvest_* + +*Removing intermediate variables to get below 5,000 vars (ETH) +keep hhid fhh clusterid strataid *weight* *wgt* region zone woreda city subcity kebele ea /*household*/ rural farm_size* *total_income* /* +*/ *percapita_income* *percapita_cons* *daily_percap_cons* *peraeq_cons* *daily_peraeq_cons* /* +*/ *income* *share* *proportion_cropvalue_sold *farm_size_agland hh_members adulteq *labor_family *labor_hired use_inorg_fert vac_* /* +*/ feed* water* lvstck_housed* ext_* use_fin_* lvstck_holding* *mortality_rate* *lost_disease* disease* any_imp* /*formal_land_rights_hh ALT:MISSING*/ /* +*/ *livestock_expenses* *ls_exp_vac* *prop_farm_prod_sold /*DYA.10.26.2020*/ *hrs_* /*months_food_insec*/ *value_assets* hhs_* *dist_agrodealer /* +*/ encs* num_crops_* multiple_crops* imprv_seed_* hybrid_seed_* *labor_total *farm_area *labor_productivity* *land_productivity* /* +*/ *wage_paid_aglabor* *labor_hired ar_h_wgt_* *yield_hv_* ar_pl_wgt_* *yield_pl_* *liters_per_* milk_animals poultry_owned *costs_dairy* *cost_per_lit* /* +*/ *egg_poultry_year* *inorg_fert_rate* *ha_planted* *cost_expli_hh* *cost_expli_ha* *monocrop_ha* *kgs_harv_mono* *cost_total_ha* /* +*/ *_exp* poverty_under_1_9 *value_crop_production* *value_harv* *value_crop_sales* *value_sold* *kgs_harvest* *total_planted_area* *total_harv_area* /* +*/ *all_area_* grew_* agactivities_hh ag_hh crop_hh livestock_hh /*fishing_hh*/ *_milk_produced* *eggs_total_year *value_eggs_produced* /* +*/ *value_livestock_products* *value_livestock_sales* *total_cons* nb_cattle_today nb_poultry_today bottom_40_percap bottom_40_peraeq /* +*/ ccf_loc ccf_usd ccf_1ppp ccf_2ppp *sales_livestock_products nb_cows_today lvstck_holding_srum nb_smallrum_today nb_chickens_today *value_pro* *value_sal* /* +*/ /*DYA 10.6.2020*/ *value_livestock_sales* *w_value_farm_production* *value_slaughtered* *value_lvstck_sold* *value_crop_sales* *sales_livestock_products* *value_livestock_sales* animals_lost12months *_inter_* *_pure_* -******************************************************************************** -*HOUSEHOLD FOOD PROVISION* -******************************************************************************** -use "${Ethiopia_ESS_W4_raw_data}/Household/sect8_hh_W4.dta", clear -*BET 05.26.2021 /* -numlist "1/12" -forval k=1/12{ - local num: word `k' of `r(numlist)' - local alph: word `k' of `c(alpha)' - ren hh_s7q07_`alph' hh_s7q07_`num' +foreach v of varlist $empty_vars { + replace `v' = . } */ -// BET 05.26.2021 14 months are asked about. taking last twelve months (july - june) -forval k=3/14 { - gen food_insecurity_`k'= (s8q07__`k'==1) -} - -egen months_food_insec = rowtotal(food_insecurity*) -*replacing those that report over 12 months of food insecurity -replace months_food_insec = 12 if months_food_insec>12 -lab var months_food_insec "Number of months of inadequate food provision" -keep household_id months_food_insec -save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_food_insecurity.dta", replace - -******************************************************************************** -*HOUSEHOLD ASSETS* -******************************************************************************** -*Cannot calculate in this instrument - questionnaire doesn't ask value of HH assets +gen ssp = (farm_size_agland <= 2 & farm_size_agland != 0) & (nb_cattle_today <= 10 & nb_chickens_today <= 50) -******************************************************************************** -*DISTANCE TO AGRO DEALERS* -******************************************************************************** -*Cannot calculate in this instrument +//////////Identifier Variables //////// +*Add variables and ren household id so dta file can be appended with dta files from other instruments +* gen hhid = hhid +gen hhid_panel = hhid +lab var hhid_panel "Panel HH identifier" +gen geography = "Ethiopia" +gen survey = "LSMS-ISA" +gen year = "2018-19" +gen instrument = 24 +//Only runs if label isn't already defined. +capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2" 13 "Tanzania NPS Wave 3" 14 "Tanzania NPS Wave 4" 15 "Tanzania NPS Wave 5" /* + */ 21 "Ethiopia ESS Wave 1" 22 "Ethiopia ESS Wave 2" 23 "Ethiopia ESS Wave 3" 24 "Ethiopia ESS Wave 4" 25 "Ethiopia ESS Wave 5" /* + */ 31 "Nigeria GHS Wave 1" 32 "Nigeria GHS Wave 2" 33 "Nigeria GHS Wave 3" 34 "Nigeria GHS Wave 4"/* + */ 41 "Malawi IHS/IHPS Wave 1" 42 "Malawi IHS/IHPS Wave 2" 43 "Malawi IHS/IHPS Wave 3" 44 "Malawi IHS/IHPS Wave 4" /* + */ 51 "Uganda NPS Wave 1" 52 "Uganda NPS Wave 2" 53 "Uganda NPS Wave 3" 54 "Uganda NPS Wave 4" 55 "Uganda NPS Wave 5" /*W6 does not exist*/ 56 "Uganda NPS Wave 7" 57 "Uganda NPS Wave 8" /* +*/ 61 "Burkina Faso EMC Wave 1" /* +*/ 71 "Mali EACI Wave 1" 72 "Mali EACI Wave 2" /* +*/ 81 "Niger ECVMA Wave 1" 82 "Niger ECVMA Wave 2" +la val instrument instrument +saveold "$Ethiopia_ESS_W4_final_data/Ethiopia_ESS_W4_household_variables.dta", replace +/* ALT: Old ******************************************************************************** *HOUSEHOLD VARIABLES ******************************************************************************** @@ -5417,7 +8150,7 @@ global wins_var_top1 /* gen wage_paid_aglabor_mixed=. //create this just to make the loop work and delete after foreach v of varlist $wins_var_top1 { - _pctile `v' [aw=weight] , p($wins_upper_thres) + _pctile `v' [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`v'=`v' replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. local l`v' : var lab `v' @@ -5429,7 +8162,7 @@ foreach v in $topcropname_area { } global wins_var_top1_gender $wins_var_top1_gender cost_total cost_expli fert_inorg_kg wage_paid_aglabor foreach v of varlist $wins_var_top1_gender { - _pctile `v' [aw=weight] , p($wins_upper_thres) + _pctile `v' [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`v'=`v' replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. local l`v' : var lab `v' @@ -5455,7 +8188,7 @@ global wins_var_top1_bott1 /* */ total_cons percapita_cons daily_percap_cons peraeq_cons daily_peraeq_cons /* */ *_monocrop_ha* dist_agrodealer foreach v of varlist $wins_var_top1_bott1 { - _pctile `v' [aw=weight] , p($wins_lower_thres $wins_upper_thres) + _pctile `v' [aw=weight_pop_rururb] , p($wins_lower_thres $wins_upper_thres) gen w_`v'=`v' replace w_`v'= r(r1) if w_`v' < r(r1) & w_`v'!=. & w_`v'!=0 /* we want to keep actual zeros */ replace w_`v'= r(r2) if w_`v' > r(r2) & w_`v'!=. @@ -5477,7 +8210,7 @@ global allyield male female mixed inter inter_male inter_female inter_mixed pure global wins_var_top1_bott1_2 area_harv area_plan harvest foreach v of global wins_var_top1_bott1_2 { foreach c of global topcropname_area { - _pctile `v'_`c' [aw=weight] , p($wins_lower_thres $wins_upper_thres) + _pctile `v'_`c' [aw=weight_pop_rururb] , p($wins_lower_thres $wins_upper_thres) gen w_`v'_`c'=`v'_`c' replace w_`v'_`c' = r(r1) if w_`v'_`c' < r(r1) & w_`v'_`c'!=0 replace w_`v'_`c' = r(r2) if (w_`v'_`c' > r(r2) & w_`v'_`c' !=.) @@ -5500,12 +8233,12 @@ foreach v of global wins_var_top1_bott1_2 { foreach c of global topcropname_area { gen yield_pl_`c'=w_harvest_`c'/w_area_plan_`c' lab var yield_pl_`c' "Yield by area planted of `c' (kgs/ha) (household)" - gen ar_pl_wgt_`c' = weight*w_area_plan_`c' + gen ar_pl_wgt_`c' = weight_pop_rururb*w_area_plan_`c' lab var ar_pl_wgt_`c' "Planted area-adjusted weight for `c' (household)" foreach g of global allyield { gen yield_pl_`g'_`c'=w_harvest_`g'_`c'/w_area_plan_`g'_`c' lab var yield_pl_`g'_`c' "Yield by area planted of `c' - (kgs/ha) (`g')" - gen ar_pl_wgt_`g'_`c' = weight*w_area_plan_`g'_`c' + gen ar_pl_wgt_`g'_`c' = weight_pop_rururb*w_area_plan_`g'_`c' lab var ar_pl_wgt_`g'_`c' "Planted area-adjusted weight for `c' (`g')" } } @@ -5514,12 +8247,12 @@ foreach c of global topcropname_area { foreach c of global topcropname_area { gen yield_hv_`c'=w_harvest_`c'/w_area_harv_`c' lab var yield_hv_`c' "Yield by area harvested of `c' (kgs/ha) (household)" - gen ar_h_wgt_`c' = weight*w_area_harv_`c' + gen ar_h_wgt_`c' = weight_pop_rururb*w_area_harv_`c' lab var ar_h_wgt_`c' "Harvested area-adjusted weight for `c' (household)" foreach g of global allyield { gen yield_hv_`g'_`c'=w_harvest_`g'_`c'/w_area_harv_`g'_`c' lab var yield_hv_`g'_`c' "Yield by area harvested of `c' - (kgs/ha) (`g')" - gen ar_h_wgt_`g'_`c' = weight*w_area_harv_`g'_`c' + gen ar_h_wgt_`g'_`c' = weight_pop_rururb*w_area_harv_`g'_`c' lab var ar_h_wgt_`g'_`c' "Harvested area-adjusted weight for `c' (`g')" } } @@ -5689,7 +8422,7 @@ global wins_var_ratios_top1 inorg_fert_rate cost_total_ha cost_expli_ha cost_exp */ mortality_rate* liters_per_largeruminant liters_per_cow liters_per_buffalo egg_poultry_year costs_dairy_percow /* */ /*DYA.10.26.2020*/ hrs_*_pc_all hrs_*_pc_any cost_per_lit_milk foreach v of varlist $wins_var_ratios_top1 { - _pctile `v' [aw=weight] , p($wins_upper_thres) + _pctile `v' [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`v'=`v' replace w_`v' = r(r1) if w_`v' > r(r1) & w_`v'!=. local l`v' : var lab `v' @@ -5708,7 +8441,7 @@ foreach v of varlist $wins_var_ratios_top1 { *Winsorizing top crop ratios foreach v of global topcropname_area { *first winsorizing costs per hectare - _pctile `v'_exp_ha [aw=weight] , p($wins_upper_thres) + _pctile `v'_exp_ha [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`v'_exp_ha = `v'_exp_ha replace w_`v'_exp_ha = r(r1) if w_`v'_exp_ha > r(r1) & w_`v'_exp_ha!=. local l`v'_exp_ha : var lab `v'_exp_ha @@ -5721,7 +8454,7 @@ foreach v of global topcropname_area { lab var w_`v'_exp_ha_`g' "`l`v'_exp_ha_`g'' - winsorized top 1%" } *winsorizing cost per kilogram - _pctile `v'_exp_kg [aw=weight] , p($wins_upper_thres) + _pctile `v'_exp_kg [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`v'_exp_kg=`v'_exp_kg replace w_`v'_exp_kg = r(r1) if w_`v'_exp_kg > r(r1) & w_`v'_exp_kg!=. local l`v'_exp_kg : var lab `v'_exp_kg @@ -5738,7 +8471,7 @@ foreach v of global topcropname_area { *now winsorize ratio only at top 1% - yield foreach c of global topcropname_area { foreach i in yield_pl yield_hv{ - _pctile `i'_`c' [aw=weight] , p($wins_upper_thres) + _pctile `i'_`c' [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_`i'_`c'=`i'_`c' replace w_`i'_`c' = r(r1) if w_`i'_`c' > r(r1) & w_`i'_`c'!=. local w_`i'_`c' : var lab `i'_`c' @@ -5855,35 +8588,35 @@ recode w_eggs_total_year w_value_eggs_produced (nonmissing=.) if egg_hh==0 *** End outliers *** *create different weights -gen w_labor_weight=weight*w_labor_total +gen w_labor_weight=weight_pop_rururb*w_labor_total lab var w_labor_weight "labor-adjusted household weights" -gen w_land_weight=weight*w_farm_area +gen w_land_weight=weight_pop_rururb*w_farm_area lab var w_land_weight "land-adjusted household weights" -gen w_aglabor_weight_all=w_labor_hired*weight +gen w_aglabor_weight_all=w_labor_hired*weight_pop_rururb lab var w_aglabor_weight_all "Hired labor-adjusted household weights" gen w_aglabor_weight_female=. // cannot create in this instrument lab var w_aglabor_weight_female "Hired labor-adjusted household weights -female workers" gen w_aglabor_weight_male=. // cannot create in this instrument lab var w_aglabor_weight_male "Hired labor-adjusted household weights -male workers" -gen weight_milk=milk_animals*weight -gen weight_egg=poultry_owned*weight +gen weight_milk=milk_animals*weight_pop_rururb +gen weight_egg=poultry_owned*weight_pop_rururb *generate area weights for monocropped plots foreach cn in $topcropname_area { - gen ar_pl_mono_wgt_`cn'_all = weight*`cn'_monocrop_ha - gen kgs_harv_wgt_`cn'_all = weight*kgs_harv_mono_`cn' + gen ar_pl_mono_wgt_`cn'_all = weight_pop_rururb*`cn'_monocrop_ha + gen kgs_harv_wgt_`cn'_all = weight_pop_rururb*kgs_harv_mono_`cn' foreach g in male female mixed { - gen ar_pl_mono_wgt_`cn'_`g' = weight*`cn'_monocrop_ha_`g' - gen kgs_harv_wgt_`cn'_`g' = weight*kgs_harv_mono_`cn'_`g' + gen ar_pl_mono_wgt_`cn'_`g' = weight_pop_rururb*`cn'_monocrop_ha_`g' + gen kgs_harv_wgt_`cn'_`g' = weight_pop_rururb*kgs_harv_mono_`cn'_`g' } } gen w_ha_planted_all = ha_planted foreach g in all female male mixed { - gen area_weight_`g'=weight*w_ha_planted_`g' + gen area_weight_`g'=weight_pop_rururb*w_ha_planted_`g' } -gen w_ha_planted_weight=w_ha_planted_all*weight +gen w_ha_planted_weight=w_ha_planted_all*weight_pop_rururb drop w_ha_planted_all -gen individual_weight=hh_members*weight -gen adulteq_weight=adulteq*weight +gen individual_weight=hh_members*weight_pop_rururb +gen adulteq_weight=adulteq*weight_pop_rururb *Rural poverty headcount ratio BET 07.20.2021 @@ -5898,8 +8631,20 @@ gen adulteq_weight=adulteq*weight // 10.583 * 2.416536 = 25.5742 ETB *NOTE: if the survey was carried out over multiple years we use the last year *This is the poverty line at the local currency in the year the survey was carried out + +* FT updated poverty estimation +/* gen poverty_under_1_9 = (daily_percap_cons<25.5742) la var poverty_under_1_9 "Household has a percapita conumption of under $1.90 in 2011 $ PPP)" +*/ + +gen poverty_under_1_9 = (daily_percap_cons<$Ethiopia_ESS_W4_poverty_190) +gen poverty_under_2_15 = (daily_percap_cons < $Ethiopia_ESS_W4_poverty_215) +gen poverty_under_npl = daily_percap_cons < $Ethiopia_ESS_W4_poverty_npl + +la var poverty_under_1_9 "Household has a percapita consumption of under $1.90 in 2011 PPP$" +la var poverty_under_2_15 "Household has a percapita consumption of under $2.15 in 2017 PPP$" +la var poverty_under_npl "Household has a percapita consumption below the national Ethiopian poverty line" *average consumption expenditure of the bottom 40% of the rural consumption expenditure distribution *By per capita consumption @@ -5915,11 +8660,11 @@ replace bottom_40_peraeq = 1 if r(r1) > w_daily_peraeq_cons & rural==1 ****Currency Conversion Factors*** gen ccf_loc = 1 lab var ccf_loc "currency conversion factor - 2018 $ETB" -gen ccf_usd = 1 / $Ethiopia_ESS_W4_exchange_rate +gen ccf_usd = $Ethiopia_ESS_W4_exchange_rate / $Ethiopia_ESS_W4_inflation lab var ccf_usd "currency conversion factor - 2018 $USD" -gen ccf_1ppp = 1 / $Ethiopia_ESS_W4_cons_ppp_dollar +gen ccf_1ppp = $Ethiopia_ESS_W4_cons_ppp_dollar / $Ethiopia_ESS_W4_inflation lab var ccf_1ppp "currency conversion factor - 2018 $Private Consumption PPP" -gen ccf_2ppp = 1 / $Ethiopia_ESS_W4_gdp_ppp_dollar +gen ccf_2ppp = $Ethiopia_ESS_W4_gdp_ppp_dollar / $Ethiopia_ESS_W4_inflation lab var ccf_2ppp "currency conversion factor - 2018 $GDP PPP" *Cleaning up output to get below 5,000 variables @@ -5935,13 +8680,12 @@ keep household_id fhh clusterid strataid *weight* *wgt* region zone woreda subc */ encs* num_crops_* multiple_crops* imprv_seed_* hybrid_seed_* *labor_total *farm_area *labor_productivity* *land_productivity* /* */ *wage_paid_aglabor* *labor_hired ar_h_wgt_* *yield_hv_* ar_pl_wgt_* *yield_pl_* *liters_per_* milk_animals poultry_owned *costs_dairy* *cost_per_lit* /* */ *egg_poultry_year* *inorg_fert_rate* *ha_planted* *cost_expli_hh* *cost_expli_ha* *monocrop_ha* *kgs_harv_mono* *cost_total_ha* /* -*/ *_exp* poverty_under_1_9 *value_crop_production* *value_harv* *value_crop_sales* *value_sold* *kgs_harvest* *total_planted_area* *total_harv_area* /* +*/ *_exp* poverty_under* *value_crop_production* *value_harv* *value_crop_sales* *value_sold* *kgs_harvest* *total_planted_area* *total_harv_area* /* */ *all_area_* grew_* agactivities_hh ag_hh crop_hh livestock_hh fishing_hh *_milk_produced* *eggs_total_year *value_eggs_produced* /* */ *value_livestock_products* *value_livestock_sales* *total_cons* nb_cattle_today nb_poultry_today bottom_40_percap bottom_40_peraeq /* */ ccf_loc ccf_usd ccf_1ppp ccf_2ppp *sales_livestock_products nb_cows_today lvstck_holding_srum nb_smallrum_today nb_chickens_today *value_pro* *value_sal* /* */ /*DYA 10.6.2020*/ *value_livestock_sales* *w_value_farm_production* *value_slaughtered* *value_lvstck_sold* *value_crop_sales* *sales_livestock_products* *value_livestock_sales* - /**create missing crop variables (no cowpea or yam) foreach x of varlist *maize* { foreach c in cowpea yam { @@ -5960,11 +8704,11 @@ foreach v of varlist $empty_vars { *Add variables and ren household id so dta file can be appended with dta files from other instruments ren household_id hhid gen hhid_panel = hhid -lab var hhid_panel "Panel HH identifier" -gen geography = "Ethiopia" +lab var hhid_panel "panel hh identifier" +gen geography = "Ethiopia" gen survey = "LSMS-ISA" -gen year = "2018-19" -gen instrument = 24 +gen year = "2018-19" //UPDATE TO MATCH SURVEY YEAR +gen instrument = 24 //Only runs if label isn't already defined. capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2" 13 "Tanzania NPS Wave 3" 14 "Tanzania NPS Wave 4" 15 "Tanzania NPS Wave 5" /* */ 21 "Ethiopia ESS Wave 1" 22 "Ethiopia ESS Wave 2" 23 "Ethiopia ESS Wave 3" 24 "Ethiopia ESS Wave 4" 25 "Ethiopia ESS Wave 5" /* @@ -5974,14 +8718,18 @@ capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2 */ 61 "Burkina Faso EMC Wave 1" /* */ 71 "Mali EACI Wave 1" 72 "Mali EACI Wave 2" /* */ 81 "Niger ECVMA Wave 1" 82 "Niger ECVMA Wave 2" -label values instrument instrument +label values instrument instrument saveold "$Ethiopia_ESS_W4_final_data/Ethiopia_ESS_W4_household_variables.dta", replace - - +*/ ******************************************************************************** *INDIVIDUAL-LEVEL VARIABLES ******************************************************************************** -use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_control_income.dta", clear +*DYA:7.3.2023 Changing this temporarily but will rewrite the individual level file entirely. It was not meant to report systematically at the individual level but instead was focused on women. + +use "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_person_ids.dta", clear //*DYA:7.3.2023 added this line +merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_control_income.dta", nogen + + merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_ag_decision.dta", nogen keep(1 3) merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_women_asset.dta", nogen keep(1 3) destring region zone , replace @@ -5995,9 +8743,8 @@ merge m:1 household_id using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_hh merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_land_rights_ind.dta", nogen recode formal_land_rights_f (.=0) if female==1 // this line will set to zero for all women for whom it is missing (i.e. regardless of ownerhsip status) la var formal_land_rights_f "Individual has documentation of land rights (at least one plot) - Women only" -*/ -*Adding individual economic activities - + +merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_plotmager.dta", nogen force merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_agworker.dta", nogen force merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_business_owners_ind.dta", nogen force merge 1:1 household_id personid using "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_wage_worker.dta", nogen force @@ -6076,24 +8823,25 @@ gen women_diet = . *Add variables and ren household id so dta file can be appended with dta files from other instruments ren household_id hhid gen hhid_panel = hhid -lab var hhid_panel "Panel HH identifier" ren personid indid -gen geography = "Ethiopia" -gen survey = "LSMS-ISA" -gen year = "2018-19" -gen instrument = 24 -label define instrument 1 "Tanzania NPS Wave 1" 2 "Tanzania NPS Wave 2" 3 "Tanzania NPS Wave 3" 4 "Tanzania NPS Wave 4" /* - */ 5 "Ethiopia ESS Wave 1" 6 "Ethiopia ESS Wave 2" 7 "Ethiopia ESS Wave 3" /* - */ 8 "Nigeria GHS Wave 1" 9 "Nigeria GHS Wave 2" 10 "Nigeria GHS Wave 3" /* - */ 11 "Tanzania TBS AgDev (Lake Zone)" 12 "Tanzania TBS AgDev (Northern Zone)" 13 "Tanzania TBS AgDev (Southern Zone)" /* - */ 14 "Ethiopia ACC Baseline" /* - */ 15 "India RMS Baseline (Bihar)" 16 "India RMS Baseline (Odisha)" 17 "India RMS Baseline (Uttar Pradesh)" 18 "India RMS Baseline (West Bengal)" /* - */ 19 "Nigeria NIBAS AgDev (Nassarawa)" 20 "Nigeria NIBAS AgDev (Benue)" 21 "Nigeria NIBAS AgDev (Kaduna)" /* - */ 22 "Nigeria NIBAS AgDev (Niger)" 23 "Nigeria NIBAS AgDev (Kano)" 24 "Nigeria NIBAS AgDev (Katsina)" -label values instrument instrument +lab var hhid_panel "panel hh identifier" +gen geography = "Ethiopia" +gen survey = "LSMS-ISA" +gen year = "2018-19" //UPDATE TO MATCH SURVEY YEAR +gen instrument = 24 +//Only runs if label isn't already defined. +capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2" 13 "Tanzania NPS Wave 3" 14 "Tanzania NPS Wave 4" 15 "Tanzania NPS Wave 5" /* + */ 21 "Ethiopia ESS Wave 1" 22 "Ethiopia ESS Wave 2" 23 "Ethiopia ESS Wave 3" 24 "Ethiopia ESS Wave 4" 25 "Ethiopia ESS Wave 5" /* + */ 31 "Nigeria GHS Wave 1" 32 "Nigeria GHS Wave 2" 33 "Nigeria GHS Wave 3" 34 "Nigeria GHS Wave 4"/* + */ 41 "Malawi IHS/IHPS Wave 1" 42 "Malawi IHS/IHPS Wave 2" 43 "Malawi IHS/IHPS Wave 3" 44 "Malawi IHS/IHPS Wave 4" /* + */ 51 "Uganda NPS Wave 1" 52 "Uganda NPS Wave 2" 53 "Uganda NPS Wave 3" 54 "Uganda NPS Wave 4" 55 "Uganda NPS Wave 5" /*W6 does not exist*/ 56 "Uganda NPS Wave 7" 57 "Uganda NPS Wave 8" /* +*/ 61 "Burkina Faso EMC Wave 1" /* +*/ 71 "Mali EACI Wave 1" 72 "Mali EACI Wave 2" /* +*/ 81 "Niger ECVMA Wave 1" 82 "Niger ECVMA Wave 2" +label values instrument instrument saveold "$Ethiopia_ESS_W4_final_data/Ethiopia_ESS_W4_individual_variables.dta", replace - +*stop ******************************************************************************** // FIELD LEVEL @@ -6121,14 +8869,14 @@ global winsorize_vars area_meas_hectares labor_total foreach p of global winsorize_vars { gen w_`p' =`p' local l`p' : var lab `p' - _pctile w_`p' [aw=weight] if w_`p'!=0 , p($wins_lower_thres $wins_upper_thres) + _pctile w_`p' [aw=weight_pop_rururb] if w_`p'!=0 , p($wins_lower_thres $wins_upper_thres) replace w_`p' = r(r1) if w_`p' < r(r1) & w_`p'!=. & w_`p'!=0 replace w_`p' = r(r2) if w_`p' > r(r2) & w_`p'!=. lab var w_`p' "`l`p'' - Winsorized top and bottom 1%" } *Winsorize plot_value_harvest at top 1% only -_pctile plot_value_harvest [aw=weight] , p($wins_upper_thres) +_pctile plot_value_harvest [aw=weight_pop_rururb] , p($wins_upper_thres) gen w_plot_value_harvest=plot_value_harvest replace w_plot_value_harvest = r(r1) if w_plot_value_harvest > r(r1) & w_plot_value_harvest != . lab var w_plot_value_harvest "Value of crop harvest on this plot - Winsorized top 1%" @@ -6140,7 +8888,7 @@ gen plot_labor_prod = w_plot_value_harvest/w_labor_total lab var plot_labor_prod "Plot labor productivity (value production/labor-day)" *Winsorize both land and labor productivity at top 1% only -gen plot_weight=w_area_meas_hectares*weight +gen plot_weight=w_area_meas_hectares*weight_pop_rururb lab var plot_weight "Weight for plots (weighted by plot area)" foreach v of varlist plot_productivity plot_labor_prod { _pctile `v' [aw=plot_weight] , p($wins_upper_thres) @@ -6149,6 +8897,16 @@ foreach v of varlist plot_productivity plot_labor_prod { local l`v' : var lab `v' lab var w_`v' "`l`v'' - Winzorized top 1%" } + +gen ccf_loc = 1 +lab var ccf_loc "currency conversion factor - 2018 $ETB" +gen ccf_usd = $Ethiopia_ESS_W4_exchange_rate / $Ethiopia_ESS_W4_inflation +lab var ccf_usd "currency conversion factor - 2018 $USD" +gen ccf_1ppp = $Ethiopia_ESS_W4_cons_ppp_dollar / $Ethiopia_ESS_W4_inflation +lab var ccf_1ppp "currency conversion factor - 2018 $Private Consumption PPP" +gen ccf_2ppp = $Ethiopia_ESS_W4_gdp_ppp_dollar / $Ethiopia_ESS_W4_inflation +lab var ccf_2ppp "currency conversion factor - 2018 $GDP PPP" + *Convert monetary values into USD and PPP global monetary_val plot_value_harvest plot_productivity plot_labor_prod @@ -6290,18 +9048,12 @@ rename v1 ETH_wave4 save "${Ethiopia_ESS_W4_created_data}/Ethiopia_ESS_W4_gendergap.dta", replace restore -/*BET.12.3.2020 - END*/ - -//////////Identifier Variables //////// -*Add variables and ren household id so dta file can be appended with dta files from other instruments -*ren household_id hhid -gen hhid_panel = hhid -lab var hhid_panel "Panel HH identifier" -ren field_id plot_id -gen geography = "Ethiopia" +gen hhid_panel = hhid +lab var hhid_panel "panel hh identifier" +gen geography = "Ethiopia" gen survey = "LSMS-ISA" -gen year = "2018-19" -gen instrument = 24 +gen year = "2018-19" //UPDATE TO MATCH SURVEY YEAR +gen instrument = 24 //Only runs if label isn't already defined. capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2" 13 "Tanzania NPS Wave 3" 14 "Tanzania NPS Wave 4" 15 "Tanzania NPS Wave 5" /* */ 21 "Ethiopia ESS Wave 1" 22 "Ethiopia ESS Wave 2" 23 "Ethiopia ESS Wave 3" 24 "Ethiopia ESS Wave 4" 25 "Ethiopia ESS Wave 5" /* @@ -6311,11 +9063,9 @@ capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2 */ 61 "Burkina Faso EMC Wave 1" /* */ 71 "Mali EACI Wave 1" 72 "Mali EACI Wave 2" /* */ 81 "Niger ECVMA Wave 1" 82 "Niger ECVMA Wave 2" -label values instrument instrument - +la val instrument instrument saveold "$Ethiopia_ESS_W4_final_data/Ethiopia_ESS_W4_field_plot_variables.dta", replace - ******************************************************************************** *SUMMARY STATISTICS ******************************************************************************** @@ -6326,4 +9076,4 @@ The code for outputting the summary statistics is in a separare dofile that is c */ *Parameters global list_instruments "Ethiopia_ESS_W4" -do "${directory}/_Summary_statistics/EPAR_UW_335_SUMMARY_STATISTICS_02.08.24.do" \ No newline at end of file +do "${directory}\_Summary_statistics\EPAR_UW_335_SUMMARY_STATISTICS.do"