Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TZA branch with new weather code #22

Merged
merged 16 commits into from
May 21, 2024
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This README describes the directory structure & should enable users to replicate all cleaning code used in the populated pre-analysis plan "[Estimating the Impact of Weather on Agriculture][3]." The main project site is on [OSF][1]. Because the weather data contains confidential information, it is not publically available. This means the weather code will not function, as that data is held by the World Bank. Without the weather data, the results cannot be replicated from raw data to final analysis. Contact Drs. Jeffrey D. Michler or Anna Josephson and they can share an intermediate - de-identified - version of the weather data for use in replicating the results.

This README was last updated on 25 May 2022.
This README was last updated on 20 May 2024.

## Index

Expand All @@ -21,6 +21,10 @@ Contributors:
* Brian McGreal (Data curation)
* Alison Conley (Data curation)
* Emil Kee-Tui (Data curation)
* Reece Branham (Data curation)
* Rodrigo Guerra Su (Data curation)
* Jacob Taylor (Data curation)
* Kieran Douglas (Data curation)

## Data cleaning

Expand All @@ -35,10 +39,9 @@ The code in this repository is primarily for replicating the cleaning of the hou
1. `weather_command`
2. `blindschemes`
3. `estout`
4. `customsave`
5. `winsor2`
6. `mdesc`
7. `distinct`
4. `winsor2`
5. `mdesc`
6. `distinct`

#### Folder structure

Expand Down
31 changes: 15 additions & 16 deletions ethiopia/household_code/eth_append_built.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: Aug 2020
* Created by: mcg
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* reads in merged data sets
Expand All @@ -11,7 +13,6 @@

* assumes
* all ethiopia data has been cleaned and merged with rainfall
* customsave.ado
* xfill.ado

* TO DO:
Expand All @@ -23,43 +24,41 @@
* **********************************************************************

* define paths
loc root = "$data/merged_data/ethiopia"
loc export = "$data/regression_data/ethiopia"
loc logout = "$data/merged_data/ethiopia/logs"
global root = "$data/merged_data/ethiopia"
global export = "$data/regression_data/ethiopia"
global logout = "$data/merged_data/ethiopia/logs"

* open log
cap log close
log using "`logout'/eth_append_build", append
cap log close
log using "$logout/eth_append_build", append


* **********************************************************************
* 1 - append data
* **********************************************************************

* import wave 1 dataset
use "`root'/wave_1/essy1_merged.dta", clear
use "$root/wave_1/essy1_merged.dta", clear

* append wave 2 dataset
append using "`root'/wave_2/essy2_merged.dta", force
append using "$root/wave_2/essy2_merged.dta", force

* append wave 3 dataset
append using "`root'/wave_3/essy3_merged", force
append using "$root/wave_3/essy3_merged", force

* check the number of observations again
count
*** 7312 observations
*** 7307 observations
count if year == 2011
*** wave 1 has 1694
*** wave 1 has 1689
count if year == 2013
*** wave 2 has 2900
count if year == 2015
*** wave 3 has 2718

* drop observations missing year 1 household id
drop if household_id == ""

* dropping 2017 weather data
drop *2017
* 35 observations deleted

* generate ethiopia panel id
egen eth_id = group(household_id)
Expand Down Expand Up @@ -108,7 +107,7 @@

* save file
qui: compress
save "`export'/eth_complete.dta", replace
save "$export/eth_complete.dta", replace

* close the log
log close
Expand Down
5 changes: 3 additions & 2 deletions ethiopia/household_code/eth_hh_masterdo.do
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
* Project: WB Weather
* Created on: May 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* Executes all wave specific Tanzania hh .do files
* outputs finished houshold data set ready to merge with weather

* assumes
* customsave.ado
* subsidiary, wave-specific .do files

* TO DO:
Expand Down
8 changes: 4 additions & 4 deletions ethiopia/household_code/wave_1/2011_geovars.do
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
* Project: WB Weather
* Created on: Oct 2020
* Created by: jdm
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.16
* Stata v.18

* does
* cleans geovars

* assumes
* customsave.ado
* raw lsms-isa data

* TO DO:
* done
Expand Down Expand Up @@ -52,8 +53,7 @@
summarize

* save file
customsave , idvar(household_id) filename("ess1_geovars.dta") ///
path("`export'") dofile(wave_1_geovars) user($user)
save "`export'/ess1_geovars.dta", replace

* close the log
log close
Expand Down
9 changes: 5 additions & 4 deletions ethiopia/household_code/wave_1/2011_sect10_ph_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: June 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 PH sec10
Expand All @@ -10,7 +12,7 @@
* hierarchy: holder > parcel > field > crop

* assumes
* customsave.ado
* raw lsms-isa data
* distinct.ado

* TO DO:
Expand Down Expand Up @@ -268,8 +270,7 @@
describe
summarize
sort holder_id ea_id parcel field crop_code
customsave , idvar(crop_id) filename(PH_SEC10.dta) path("`export'") ///
dofile(PP_SEC10) user($user)
save "`export'/PH_SEC10.dta", replace

* close the log
log close
6 changes: 4 additions & 2 deletions ethiopia/household_code/wave_1/2011_sect11_ph_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: July 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 PH sec11
Expand All @@ -10,7 +12,7 @@
* hierarchy: holder > parcel > field > crop

* assumes
* customsave.ado
* raw lsms-isa data

* TO DO:
* done
Expand Down
6 changes: 4 additions & 2 deletions ethiopia/household_code/wave_1/2011_sect12_ph_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: July 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 PH sec12
Expand All @@ -11,7 +13,7 @@
* generates price data

* assumes
* customsave.ado
* raw lsms-isa data

* TO DO:
* done
Expand Down
11 changes: 6 additions & 5 deletions ethiopia/household_code/wave_1/2011_sect1_hh_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: June 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 HH sec1
Expand All @@ -10,11 +12,11 @@
* seems to very roughly correspond to Malawi ag-modI and ag-modO

* assumes
* customsave.ado
* raw lsms-isa data
* distinct.ado

* TO DO:
*
* done


* **********************************************************************
Expand Down Expand Up @@ -79,8 +81,7 @@
describe
summarize
sort hhid ea_id
customsave , idvar(individual_id) filename(HH_SEC1.dta) path("`export'") ///
dofile(HH_SEC1) user($user)
save "`export'/HH_SEC1.dta", replace

* close the log
log close
Expand Down
11 changes: 6 additions & 5 deletions ethiopia/household_code/wave_1/2011_sect3_pp_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: June 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 PP sec3
Expand All @@ -10,11 +12,11 @@
* seems to correspond to Malawi ag-modC and ag-modJ

* assumes
* customsave.ado
* raw lsms-isa data
* distinct.ado

* TO DO:
* number of obs are inconsistent, meat needs to get updated
* done


* **********************************************************************
Expand Down Expand Up @@ -429,8 +431,7 @@
describe
summarize
sort holder_id parcel field
customsave , idvar(field_id) filename(PP_SEC3.dta) path("`export'") ///
dofile(PP_SEC3) user($user)
save "`export'/PP_SEC3.dta", replace

* close the log
log close
Expand Down
10 changes: 6 additions & 4 deletions ethiopia/household_code/wave_1/2011_sect4_pp_w1.do
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
* Project: WB Weather
* Created on: July 2020
* Created by: McG
* Stata v.16
* Edited on: 20 May 2024
* Edited by: jdm
* Stata v.18

* does
* cleans Ethiopia household variables, wave 1 PP sec4
Expand All @@ -10,10 +12,11 @@
* some information on inputs

* assumes
* raw lsms-isa data
* customsave.ado

* TO DO:
* inconsistent #s of values for different variables
* done


* **********************************************************************
Expand Down Expand Up @@ -142,8 +145,7 @@
describe
summarize
sort holder_id parcel field crop_code
customsave , idvar(crop_id) filename(PP_SEC4.dta) path("`export'") ///
dofile(PP_SEC4) user($user)
save "`export'.PP_SEC4.dta", replace

* close the log
log close
Loading