Skip to content

Commit 6a431b6

Browse files
Corrections to MWI and NGA (#580)
* Malawi: * Changes to crop yield accounting in MWI W4 - corrects issue with kgs_harvested. * Changes to crop yield accounting to reduce code * Changes to top crops for MWI W3, where there was a transposed crop code; overall edits to the list across the * Temporarily removed a section from the consumption section because it wasn't collapsing properly - to be addressed in a future update. * Nigeria * Adjustment to inflation in W5 * Corrected year in monetary variable labels in all waves --------- Co-authored-by: David Aplyn <daplyn@uw.edu>
1 parent fe6d07b commit 6a431b6

File tree

12 files changed

+428
-370
lines changed

12 files changed

+428
-370
lines changed

Malawi IHS/Malawi IHS Wave 1/EPAR_UW_Malawi_IHS_W1.do

Lines changed: 170 additions & 151 deletions
Large diffs are not rendered by default.

Malawi IHS/Malawi IHS Wave 2/EPAR_UW_Malawi_IHS_W2.do

Lines changed: 66 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ paprika * *
243243
other * *
244244
*/
245245

246-
global topcropname_area "maize tobacc grdnt pigpea nkhwni beans sorgum soy rice cotton swtptt pmill"
247-
global topcrop_area "1 5 11 36 42 34 32 35 17 37 28 33" //corresponding numeric crop codes
248-
global comma_topcrop_area "1, 5, 11, 36, 42, 34, 32, 35, 17, 37, 28, 33"
246+
247+
global topcropname_area "maize sorgum pigpea tobaco soy grdnt beans rice cotton swtptt pmill cassav mangos"
248+
global topcrop_area "1 32 36 5 35 11 34 17 37 28 33 49 52"
249+
global comma_topcrop_area "1, 32, 36, 5, 35, 11, 34, 17, 37, 28, 33, 49, 52"
249250
global nb_topcrops : list sizeof global(topcropname_area) // Gets the current length of the global macro list "topcropname_area"
250251

251252
//display "$nb_topcrops"
@@ -4588,15 +4589,26 @@ save "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_ownasset.dta", replace
45884589
*CROP YIELDS*
45894590
********************************************************************************
45904591
use "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_all_plots.dta", clear
4591-
gen number_trees_planted_mango = number_trees_planted if crop_code == 52
4592-
recode crop_code ( 53 54 56 57 58 59 60 61 62 63 64=100) // recode to "other fruit": mango, orange, papaya, avocado, guava, lemon, tangerine, peach, poza, masuku, masau, pineapple
4593-
gen number_trees_planted_other_fruit = number_trees_planted if crop_code == 100
4594-
gen number_trees_planted_cassava = number_trees_planted if crop_code == 49
4595-
gen number_trees_planted_tea = number_trees_planted if crop_code == 50
4596-
gen number_trees_planted_coffee = number_trees_planted if crop_code == 51
4597-
recode number_trees_planted_mango number_trees_planted_other_fruit number_trees_planted_cassava number_trees_planted_tea number_trees_planted_coffee (.=0)
4598-
collapse (sum) number_trees_planted*, by(hhid)
4599-
save "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_trees.dta", replace
4592+
// gen number_trees_planted_mango = number_trees_planted if crop_code == 52
4593+
// recode crop_code ( 53 54 56 57 58 59 60 61 62 63 64=100) // recode to "other fruit": mango, orange, papaya, avocado, guava, lemon, tangerine, peach, poza, masuku, masau, pineapple
4594+
// gen number_trees_planted_other_fruit = number_trees_planted if crop_code == 100
4595+
// gen number_trees_planted_cassava = number_trees_planted if crop_code == 49
4596+
// gen number_trees_planted_tea = number_trees_planted if crop_code == 50
4597+
// gen number_trees_planted_coffee = number_trees_planted if crop_code == 51
4598+
// recode number_trees_planted_mango number_trees_planted_other_fruit number_trees_planted_cassava number_trees_planted_tea number_trees_planted_coffee (.=0)
4599+
// collapse (sum) number_trees_planted*, by(hhid)
4600+
// save "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_trees.dta", replace
4601+
gen grew_=1
4602+
gen harvested_ = (kg_harvest!=0 & kg_harvest!=.) | (ha_harvest!=0 & ha_harvest!=.)
4603+
collapse (max) grew_ harvested_, by(hhid crop_code)
4604+
merge m:1 crop_code using "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_cropname_table.dta", nogen keep(3)
4605+
keep hhid crop_name grew_ harvested_
4606+
fillin hhid crop_name
4607+
drop _fillin
4608+
recode grew_ harvested_ (.=0)
4609+
reshape wide grew_ harvested_, i(hhid) j(crop_name) string
4610+
tempfile grew_crops
4611+
save `grew_crops'
46004612

46014613
use "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_all_plots.dta", clear
46024614
gen no_harvest=ha_harvest==.
@@ -4635,7 +4647,7 @@ gen no_harvest=ha_harvest==.
46354647
local suffix : subinstr local vars2 "area_plan_" "", all
46364648
foreach var in `suffix' {
46374649
replace area_plan_`var' = . if area_plan_`var'==0
4638-
replace harvest_`var'=. if area_plan_`var'==. | (harvest_`var'==0 & no_harvest==1)
4650+
replace harvest_`var'=. if /*area_plan_`var'==. |*/ (harvest_`var'==0 & no_harvest==1)
46394651
replace area_harv_`var'=. if area_plan_`var'==. | (area_harv_`var'==0 & no_harvest==1)
46404652
}
46414653
drop no_harvest
@@ -4713,11 +4725,17 @@ gen kgs_harvest_ = harvest_
47134725
drop crop_code*
47144726
unab vars : *_
47154727
reshape wide `vars', i(hhid) j(crop_name) string
4716-
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_trees.dta"
4717-
collapse (sum) harvest* area_harv* area_plan* total_planted_area* total_harv_area* kgs_harvest* value_harv* value_sold* number_trees_planted* , by(hhid)
4718-
recode harvest* area_harv* area_plan* kgs_harvest* total_planted_area* total_harv_area* value_harv* value_sold* (0=.)
4719-
egen kgs_harvest = rowtotal(kgs_harvest_*)
4720-
la var kgs_harvest "Quantity harvested of all crops (kgs) (household) (summed accross all seasons)"
4728+
// merge 1:1 hhid using "${MWI_IHPS_W2_created_data}\MWI_IHPS_W2_trees.dta"
4729+
// collapse (sum) harvest* area_harv* area_plan* total_planted_area* total_harv_area* kgs_harvest* value_harv* value_sold* number_trees_planted* , by(hhid)
4730+
// recode harvest* area_harv* area_plan* kgs_harvest* total_planted_area* total_harv_area* value_harv* value_sold* (0=.)
4731+
collapse (sum) harvest* area_harv* area_plan* total_planted_area* total_harv_area* kgs_harvest* value_harv* value_sold* , by(hhid)
4732+
merge 1:1 hhid using `grew_crops'
4733+
recode area_plan* (0=.)
4734+
foreach p of global topcropname_area {
4735+
recode harvest*_`p' area_harv*_`p' kgs_harvest*_`p' total_planted_area*_`p' total_harv_area*_`p' value_harv*_`p' value_sold*_`p' (0=.) if grew_`p' == 0
4736+
}
4737+
// egen kgs_harvest = rowtotal(kgs_harvest_*)
4738+
// la var kgs_harvest "Quantity harvested of all crops (kgs) (household) (summed accross all seasons)"
47214739

47224740
*ren variables
47234741
foreach p of global topcropname_area {
@@ -4764,12 +4782,12 @@ foreach p of global topcropname_area {
47644782
lab var area_plan_inter_mixed_`p' "Area planted of `p' (ha) - intercrop (mixed-managed plots)"
47654783
}
47664784

4767-
foreach p of global topcropname_area {
4768-
gen grew_`p'=(total_harv_area_`p'!=. & total_harv_area_`p'!=.0 ) | (total_planted_area_`p'!=. & total_planted_area_`p'!=.0)
4769-
lab var grew_`p' "1=Household grew `p'"
4770-
gen harvested_`p'= (total_harv_area_`p'!=. & total_harv_area_`p'!=.0 )
4771-
lab var harvested_`p' "1= Household harvested `p'"
4772-
}
4785+
// foreach p of global topcropname_area {
4786+
// gen grew_`p'=(total_harv_area_`p'!=. & total_harv_area_`p'!=.0 ) | (total_planted_area_`p'!=. & total_planted_area_`p'!=.0)
4787+
// lab var grew_`p' "1=Household grew `p'"
4788+
// gen harvested_`p'= (total_harv_area_`p'!=. & total_harv_area_`p'!=.0 )
4789+
// lab var harvested_`p' "1= Household harvested `p'"
4790+
// }
47734791
save "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_yield_hh_crop_level.dta", replace
47744792

47754793
* VALUE OF CROP PRODUCTION
@@ -5110,7 +5128,7 @@ ren ea ea_id
51105128
merge m:1 ea_id hhid using "${MWI_IHPS_W2_appended_data}/ConsAggW2.dta", nogen keep(3)
51115129
gen annual_val_fdcons=(val_fdcons*52)
51125130
save "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_agg_consumption.dta", replace
5113-
5131+
/* To fix: right now this is a very large file.
51145132
use "${MWI_IHPS_W2_appended_data}\hh_mod_i1_13.dta", clear
51155133
append using "${MWI_IHPS_W2_appended_data}\hh_mod_i2_13.dta"
51165134
append using "${MWI_IHPS_W2_appended_data}\hh_mod_j_13.dta"
@@ -5138,7 +5156,7 @@ ren rexp* rexp*new
51385156
merge m:1 hhid using "${MWI_IHPS_W2_appended_data}/ConsAggW2.dta", nogen keep (3)
51395157
*Our method produces differnces from the World Bank consumption method. This code allows you to compare both panel and cross section.
51405158
save "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_aggregate_consumption.dta", replace
5141-
5159+
*/
51425160
*first get adult equivalent
51435161
use "${MWI_IHPS_W2_appended_data}/ConsAggW2.dta", clear
51445162
collapse (sum) adulteq, by(hhid)
@@ -5269,36 +5287,37 @@ lab var crop_income "Net crop revenue (value of production minus crop expenses)"
52695287
*Top crop costs by area planted
52705288
foreach c in $topcropname_area {
52715289
capture confirm file "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_inputs_`c'.dta"
5272-
if _rc==0 {
5273-
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_inputs_`c'.dta", nogen //All expenses are in here now.
5274-
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_`c'_monocrop_hh_area.dta", nogen
5275-
}
5290+
if _rc==0 merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_inputs_`c'.dta", nogen //All expenses are in here now.
5291+
capture confirm file "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_`c'_monocrop_hh_area.dta"
5292+
if _rc==0 merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_`c'_monocrop_hh_area.dta", nogen
52765293
}
52775294

52785295
global empty_crops ""
52795296

52805297
foreach c in $topcropname_area {
5281-
capture confirm var `c'_monocrop //Check to make sure this isn't empty.
5282-
if !_rc {
5283-
egen `c'_exp = rowtotal(val_*_`c'_hh) //Only explicit costs for right now; add "exp" and "imp" tag to variables to disaggregate in future
5298+
la var `c'_monocrop_ha "Total `c' monocrop hectares planted - Household"
5299+
foreach v in herb inorg labor orgfert pest plotrent {
5300+
capture confirm var val_`v'_`c'_hh
5301+
if _rc {
5302+
gen val_`v'_`c'_hh=.
5303+
}
5304+
}
5305+
egen num_miss = rmiss(val_*_`c'_hh)
5306+
egen `c'_exp = rowtotal(val_*_`c'_hh) if num_miss!=6 //Only explicit costs for right now; add "exp" and "imp" tag to variables to disaggregate in future; will be missing if all subcategories are missing.
52845307
lab var `c'_exp "Crop production costs(explicit)-Monocrop `c' plots only"
5285-
la var `c'_monocrop_ha "Total `c' monocrop hectares planted - Household"
5308+
52865309
*disaggregate by gender of plot manager
52875310
foreach i in male female mixed{
5288-
egen `c'_exp_`i' = rowtotal(val_*_`c'_`i')
5311+
egen `c'_exp_`i' = rowtotal(val_*_`c'_`i') if num_miss!=6
52895312
local l`c'_exp : var lab `c'_exp
52905313
la var `c'_exp_`i' "`l`c'_exp' - `i' managed plots"
52915314
}
52925315
replace `c'_exp = . if `c'_monocrop_ha==. // set to missing if the household does not have any monocropped plots
5293-
foreach i in male female mixed{
5316+
foreach i in male female mixed {
52945317
replace `c'_exp_`i' = . if `c'_monocrop_ha_`i'==.
52955318
}
5319+
drop num_miss
52965320
}
5297-
else {
5298-
global empty_crops $empty_crops `c'
5299-
}
5300-
5301-
}
53025321

53035322

53045323
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_land_rights_hh.dta", nogen
@@ -5435,7 +5454,7 @@ merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_fertilizer_applic
54355454
*Agricultural wage rate
54365455
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_ag_wage.dta", nogen
54375456
*Crop yields
5438-
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_yield_hh_crop_level.dta", nogen
5457+
// merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_yield_hh_crop_level.dta", nogen
54395458
*Total area planted and harvested accross all crops, plots, and seasons
54405459
merge 1:1 hhid using "${MWI_IHPS_W2_created_data}/MWI_IHPS_W2_hh_area_planted_harvested_allcrops.dta", nogen
54415460
*Household diet
@@ -5521,11 +5540,11 @@ lab var fishing_hh "1= Household has some fishing income"
55215540
*Recoding missings to 0 for households growing crops
55225541
recode grew* (.=0)
55235542
*all rural households growing specific crops
5524-
forvalues k=1(1)$nb_topcrops {
5525-
local cn: word `k' of $topcropname_area
5526-
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
5527-
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
5528-
}
5543+
// forvalues k=1(1)$nb_topcrops {
5544+
// local cn: word `k' of $topcropname_area
5545+
// 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
5546+
// 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
5547+
// }
55295548

55305549
*all rural households engaged in livestcok production of a given species //data not available
55315550
foreach i in lrum srum poultry{
@@ -6193,7 +6212,6 @@ capture label define instrument 11 "Tanzania NPS Wave 1" 12 "Tanzania NPS Wave 2
61936212
*/ 71 "Mali EACI Wave 1" 72 "Mali EACI Wave 2" /*
61946213
*/ 81 "Niger ECVMA Wave 1" 82 "Niger ECVMA Wave 2"
61956214
saveold "${MWI_IHPS_W2_final_data}/MWI_IHPS_W2_household_variables.dta", replace // NOTE TO DEV: filename MWI... is intentionally different from standard file naming format. Keep MWI for Summary Stat file compatibility
6196-
61976215
********************************************************************************
61986216
*INDIVIDUAL LEVEL VARIABLES*
61996217
********************************************************************************

0 commit comments

Comments
 (0)