-------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\andrkot\Frischsenteret Dropbox\Andreas Kotsadam\cursor\Fe
> rtility_Ethiopia\replication\build_release\build_release_log.txt
  log type:  text
 opened on:  27 Jul 2026, 11:26:52

. 
. *----------------------------------------------------------------------------
> --
. * 0. ID crosswalk: N_Id -> id_anon (random), over the union of all three file
> s
. *----------------------------------------------------------------------------
> --
. tempfile xa xb xc idx hf

. use N_Id using "$CRE\FU_6th_norest.dta", clear

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. save `xa'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000002.tmp saved as .dta
    format

. use N_Id using "$CRE\panel_long.dta", clear

. drop if missing(N_Id)
(0 observations deleted)

. duplicates drop

Duplicates in terms of all variables

(8,994 observations deleted)

. save `xb'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000003.tmp saved as .dta
    format

. use N_Id using "$CRE\cumulative.dta", clear

. drop if missing(N_Id)
(0 observations deleted)

. duplicates drop

Duplicates in terms of all variables

(7,912 observations deleted)

. save `xc'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000004.tmp saved as .dta
    format

. use `xa', clear

. append using `xb'
(variable N_Id was str5, now str16 to accommodate using data's values)

. append using `xc'

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(2,962 observations deleted)

. set seed 20260727

. gen double _u = runiform()

. sort _u

. gen long id_anon = _n

. drop _u

. save `idx'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000005.tmp saved as .dta
    format

. di as text "crosswalk built: " _N " unique ids"
crosswalk built: 1842 unique ids

. 
. *----------------------------------------------------------------------------
> --
. * 1. hfias_index: balanced food-insecurity z-index (from cumulative)
. *----------------------------------------------------------------------------
> --
. use N_Id wave hfias orig_treatment_r using "$CRE\cumulative.dta", clear

. forvalues w = 2/7 {
  2.     quietly su hfias if wave==`w' & orig_treatment_r==0
  3.     gen double zval`w'x = (hfias - r(mean))/r(sd) if wave==`w'
  4. }
(8,160 missing values generated)
(8,268 missing values generated)
(8,373 missing values generated)
(8,381 missing values generated)
(8,472 missing values generated)
(8,624 missing values generated)

. egen double zval = rowtotal(zval2x zval3x zval4x zval5x zval6x zval7x), missi
> ng
(1,508 missing values generated)

. keep if inrange(wave,2,7)
(1,499 observations deleted)

. keep N_Id wave zval

. reshape wide zval, i(N_Id) j(wave)
(j = 2 3 4 5 6 7)

Data                               Long   ->   Wide
-----------------------------------------------------------------------------
Number of observations            8,255   ->   1,727       
Number of variables                   3   ->   7           
j variable (6 values)              wave   ->   (dropped)
xij variables:
                                   zval   ->   zval2 zval3 ... zval7
-----------------------------------------------------------------------------

. egen byte n_waves_obs = rownonmiss(zval2 zval3 zval4 zval5 zval6 zval7)

. egen double hfias_index = rowmean(zval2 zval3 zval4 zval5 zval6 zval7)

. replace hfias_index = . if n_waves_obs < 6
(939 real changes made, 939 to missing)

. keep N_Id hfias_index

. save `hf'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000006.tmp saved as .dta
    format

. 
. *----------------------------------------------------------------------------
> --
. * 1b. Contraceptive use (binary "uses any method", waves 2-6) from raw wave f
> iles
. *----------------------------------------------------------------------------
> --
. tempfile cu cw2 cw3 cw4 cw5 cw6

. capture program drop mkuse

. program define mkuse
  1.     args src new
  2.     capture decode `src', gen(_s)
  3.     if _rc gen _s = ""
  4.     gen byte `new' = .
  5.     replace `new' = 1 if lower(_s)=="yes"
  6.     replace `new' = 0 if lower(_s)=="no"
  7.     drop _s
  8. end

. use "$GBV/playdata_november18.dta", clear

. mkuse L29 use_w2
(1,499 missing values generated)
(874 real changes made)
(389 real changes made)

. keep N_Id use_w2

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(0 observations are duplicates)

. save `cw2'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000008.tmp saved as .dta
    format

. 
. use "$GBV/2nd_Followup_21092019_clean.dta", clear

. mkuse l29 use_w3
(1,488 missing values generated)
(997 real changes made)
(491 real changes made)

. rename n_id N_Id

. keep N_Id use_w3

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(0 observations are duplicates)

. save `cw3'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000009.tmp saved as .dta
    format

. 
. use "$GBV/3rd_followup_Oct30.dta", clear

. mkuse l29 use_w4
(1,382 missing values generated)
(916 real changes made)
(466 real changes made)

. rename n_id N_Id

. keep N_Id use_w4

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(0 observations are duplicates)

. save `cw4'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_00000a.tmp saved as .dta
    format

. 
. use "$GBV/fourth_fu_1375_final_15032020.dta", clear

. mkuse l29 use_w5
(1,375 missing values generated)
(826 real changes made)
(492 real changes made)

. rename n_id N_Id

. keep N_Id use_w5

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(0 observations are duplicates)

. save `cw5'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_00000b.tmp saved as .dta
    format

. 
. use "$GBV/CMI_Fifth_Followup_25042021_Final_Cleaned_Version.dta", clear

. mkuse l29 use_w6
(1,283 missing values generated)
(774 real changes made)
(509 real changes made)

. rename n_id N_Id

. keep N_Id use_w6

. duplicates drop N_Id, force

Duplicates in terms of N_Id

(0 observations are duplicates)

. save `cw6'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_00000c.tmp saved as .dta
    format

. 
. use `cw2', clear

. merge 1:1 N_Id using `cw3', nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                           637
        from master                       324  
        from using                        313  

    Matched                             1,175  
    -----------------------------------------

. merge 1:1 N_Id using `cw4', nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                           430
        from master                       430  
        from using                          0  

    Matched                             1,382  
    -----------------------------------------

. merge 1:1 N_Id using `cw5', nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                           477
        from master                       457  
        from using                         20  

    Matched                             1,355  
    -----------------------------------------

. merge 1:1 N_Id using `cw6', nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                           549
        from master                       549  
        from using                          0  

    Matched                             1,283  
    -----------------------------------------

. save `cu'
file C:\Users\andrkot\AppData\Local\Temp\ST_9248_000007.tmp saved as .dta
    format

. 
. *----------------------------------------------------------------------------
> --
. * 2. FU_slim  (cross-section, endline)
. *----------------------------------------------------------------------------
> --
. use "$CRE\FU_6th_norest.dta", clear

. 
. * --- pre-compute derived-from-identifying variables ---
. * KM duration (months) and event, from birth timing + interview dates
. gen byte km_event = days_to_birth_after < .

. gen double km_duration = days_to_birth_after/30
(676 missing values generated)

. replace km_duration = (intdat_7 - intdat_1)/30 if km_duration==.
(343 real changes made)

. * within-region high-wage indicator, from factory wage + region
. bysort base_A4: egen double reg_med_wage = median(mw_fac) if !missing(mw_fac)
(6 missing values generated)

. gen byte mw_fac_hi_within = (mw_fac >= reg_med_wage) if !missing(mw_fac)
(6 missing values generated)

. * no_conf_f from the factory conflicts item
. capture confirm variable no_conf_f

. if _rc {
.     merge m:1 factory1 using "$FAC", keepusing(havetherebeenanyconflictsrelat
> ed) keep(master match) nogen
(label wp already defined)

    Result                      Number of obs
    -----------------------------------------
    Not matched                            31
        from master                        31  
        from using                          0  

    Matched                             1,432  
    -----------------------------------------
.     capture tab havetherebeenanyconflictsrelated, gen(conf_f)
.     capture rename conf_f1 no_conf_f
. }

. * hfias_index + contraceptive-use indicators
. merge 1:1 N_Id using `hf', keep(master match) nogen
(variable N_Id was str5, now str16 to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                           105
        from master                       105  
        from using                          0  

    Matched                             1,358  
    -----------------------------------------

. merge 1:1 N_Id using `cu', keep(master match) nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                             1,463  
    -----------------------------------------

. 
. * --- anonymize ---
. merge 1:1 N_Id using `idx', keep(master match) nogen keepusing(id_anon)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                             1,463  
    -----------------------------------------

. 
. keep id_anon orig_treatment attrit block ///
>      any_child Ab08 any_child_w7nr nr_births_w7 wanted_nrch appr_age_fkid ///
>      married same_partner never_moved nr_kids_dying ///
>      months_worked any_work_month ///
>      physical_violence_3m eviol_3m h_fs_nrch h_fs_contraception h_fs_index_sm
> all conf_J5 ///
>      nr_births_w1 nr_births_w2 nr_births_w3 nr_births_w4 nr_births_w5 nr_birt
> hs_w6 ///
>      any_child_w1nr any_child_w2nr any_child_w3nr any_child_w4nr any_child_w5
> nr any_child_w6nr ///
>      any_child_y1 any_child_y2 any_child_y3 any_child_y4 any_child_y5 any_chi
> ld_y6 any_child_y7 any_child_y8 any_child_y9 ///
>      nr_births_y1 nr_births_y2 nr_births_y3 nr_births_y4 nr_births_y5 nr_birt
> hs_y6 nr_births_y7 nr_births_y8 nr_births_y9 ///
>      months_since_bl1 months_since_bl2 months_since_bl3 months_since_bl4 mont
> hs_since_bl5 months_since_bl6 months_since_bl7 ///
>      base_any_child base_B11 base_partner_w_more_ch base_wanted_nrch base_app
> r_age_fkid ///
>      base_K1 base_age base_Muslim base_Protestant base_edu_yrs base_leisure b
> ase_soc_rel ///
>      base_hhinc6 base_any_t base_nr_t z_base_age z_base_age_t ///
>      K1_53 K1_12C Interview_Type mw_fac_hi mw_fac_hi_within Asian American Et
> hiopian share_w prodyear no_conf_f ///
>      hfias_index km_duration km_event ///
>      asp_eduyears_d asp_age_marry_d asp_imp_earn_own_d asp_nrch_d asp_eduyear
> s_s asp_nrch_s ///
>      use_w2 use_w3 use_w4 use_w5 use_w6 ///
>      em* m_* bl_fe*

. order id_anon

. compress
  variable id_anon was long now int
  (2,926 bytes saved)

. label data "FU_slim (anonymized release) -- Female Jobs and Fertility"

. save "$OUT\FU_slim.dta", replace
file C:\Users\andrkot\Frischsenteret Dropbox\Andreas
    Kotsadam\cursor\Fertility_Ethiopia\replication\data\FU_slim.dta saved

. di as text "FU_slim saved: " _N " obs, " c(k) " vars"
FU_slim saved: 1463 obs, 247 vars

. 
. *----------------------------------------------------------------------------
> --
. * 3. panel_slim  (person-wave)
. *----------------------------------------------------------------------------
> --
. use "$CRE\panel_long.dta", clear

. drop if missing(N_Id)
(0 observations deleted)

. * bring K1_53 in from the endline file (needed for the can/cannot split)
. merge m:1 N_Id using "$CRE\FU_6th_norest.dta", keepusing(K1_53) keep(master m
> atch) nogen
(label tlab already defined)
(label a3 already defined)
(label a4 already defined)
(label a7_01 already defined)
(label a8_01 already defined)
(label ga_2 already defined)
(label ga_6 already defined)
(label k1 already defined)
(label k13 already defined)
(label k14 already defined)
(label id_r7 already defined)
(label A_3 already defined)

    Result                      Number of obs
    -----------------------------------------
    Not matched                           252
        from master                       252  
        from using                          0  

    Matched                            10,241  
    -----------------------------------------

. merge m:1 N_Id using `idx', keep(master match) nogen keepusing(id_anon)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                            10,493  
    -----------------------------------------

. capture confirm variable orig_treatment

. if _rc capture clonevar orig_treatment = orig_treatment_r

. keep id_anon wave orig_treatment orig_treatment_r any_wage_job_last6_r_alt nr
> _births_r ///
>      any_child_w1nr any_child_r mw_fac_hi base_hhinc6 K1_53 ///
>      hours_r leisure_r eating soc_rel_r school sleeping travel unpaid hh_work
> _r care ///
>      em* m_* bl_fe*

. order id_anon wave

. compress
  variable id_anon was long now int
  variable orig_treatment_r was float now byte
  variable nr_births_r was float now byte
  variable any_child_r was float now byte
  variable any_wage_job_last6_r_alt was float now byte
  variable orig_treatment was float now byte
  variable unpaid was double now byte
  (251,832 bytes saved)

. label data "panel_slim (anonymized release)"

. save "$OUT\panel_slim.dta", replace
file C:\Users\andrkot\Frischsenteret Dropbox\Andreas
    Kotsadam\cursor\Fertility_Ethiopia\replication\data\panel_slim.dta saved

. di as text "panel_slim saved: " _N " obs, " c(k) " vars"
panel_slim saved: 10493 obs, 167 vars

. 
. *----------------------------------------------------------------------------
> --
. * 4. cumulative_slim  (person-wave; income/savings)
. *----------------------------------------------------------------------------
> --
. use "$CRE\cumulative.dta", clear

. drop if missing(N_Id)
(0 observations deleted)

. merge m:1 N_Id using `idx', keep(master match) nogen keepusing(id_anon)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                             9,754  
    -----------------------------------------

. keep id_anon wave orig_treatment_r hhinc6 savings inc6 ea_last6_r fac_last6_r
>  ///
>      any_wage_job_last6_r_alt any_child_r mw_fac_hi hfias em* m_* bl_fe*

. order id_anon wave

. compress
  variable id_anon was long now int
  variable orig_treatment_r was float now byte
  variable any_child_r was float now byte
  variable any_wage_job_last6_r_alt was float now byte
  variable fac_last6_r was double now byte
  (175,572 bytes saved)

. label data "cumulative_slim (anonymized release)"

. save "$OUT\cumulative_slim.dta", replace
file C:\Users\andrkot\Frischsenteret Dropbox\Andreas
    Kotsadam\cursor\Fertility_Ethiopia\replication\data\cumulative_slim.dta
    saved

. di as text "cumulative_slim saved: " _N " obs, " c(k) " vars"
cumulative_slim saved: 9754 obs, 158 vars

. 
. log close
      name:  <unnamed>
       log:  C:\Users\andrkot\Frischsenteret Dropbox\Andreas Kotsadam\cursor\Fe
> rtility_Ethiopia\replication\build_release\build_release_log.txt
  log type:  text
 closed on:  27 Jul 2026, 11:26:54
-------------------------------------------------------------------------------
