********************************************************* *IV variables, requested by Filiz GARIP on Sep 16th, 2011 ** **** **** **** *Created: 21 September 2011 6pm by Burak Eskici *Updated: 21 September 2011 8pm by Burak Eskici ************************************************************************* * These data files should be copied to root directory * *********************************************************************** ***sibs94_ind.dta ~ 1994 Sibling Network individual level ~ from Temp Data/Burak/Data Files ***indiv94.dta ~ individual data 1994 ~ from ORIGINAL STATA FILES ***personid.dta ~ NRPID data ~ from ORIGINAL STATA FILES ***mremit94.dta ~ migrant remittance data 1994 ~ from ORIGINAL STATA FILES *************************************************************************** clear set mem 1000m cd "D:/ws" use "indiv94.dta", clear rename cep94 rcep sort hhid94 rcep, stable order hhid94 rcep save "indiv94r.dta", replace use "personid.dta", clear keep hhid94 cep94 vill84 nrpid mid mcep8 sort mid mcep8, stable drop if missing(mid) save "personid94m.dta",replace use "mremit94.dta", clear order mid mcep8 sort mid mcep8, stable drop q9_7_11 q9_7_12 q9_7_13 q9_7_141 q9_7_142 q9_7_143 q9_7_144 q9_7_145 //migrant receives --DROP them rename q9_7_21 money rename q9_7_22 mon_times rename q9_7_23 mon_amnt rename q9_7_241 cloth rename q9_7_242 food rename q9_7_243 hhitem rename q9_7_244 appl rename q9_7_245 vehicle merge m:1 mid mcep8 using "personid94m.dta" keep if _merge==3 drop _merge order mid mcep8 nrpid hhid94 vill84 * Reshape the data so that there is one observation for each cep number q9_7_c1 to q9_7_c9 rename q9_7_c1 rcep1 rename q9_7_c2 rcep2 rename q9_7_c3 rcep3 rename q9_7_c4 rcep4 rename q9_7_c5 rcep5 rename q9_7_c6 rcep6 rename q9_7_c7 rcep7 rename q9_7_c8 rcep8 rename q9_7_c9 rcep9 * Generate a unique id for reshaping (mid mcp8 does not uniquely identify migrants, as a mig can send remittances to multiple cep no.s from the origin hh. gen id=_n reshape long rcep,i(id) j(rcepno) drop id rcepno * drop all the observations with missing rcep number - it means no recipients are identified. drop if rcep=="998" * Get the q1 for recipient cep numbers (rcep) from the indiv94.dta. sort hhid94 rcep, stable merge hhid94 rcep using "indiv94r.dta", keep(q1) update drop if _merge==2 drop _merge * Keep only the individuals currently living in the hh (that is, q1==1). /* keep if q1==1 * For each mid mcep8, compute the amount of remittances received. Note each row represents a person in the hh, and ideally, since the migrant is remitting to the hh as a whole, the rows should be equal for a migrant. They usually are. But in some cases there are inconsistencies. In those cases, we will take the highest occurring number, i.e. the mode. * q9_7_21 identifies if mig sends money to hh in the last 12 months. replace q9_7_21 = . if q9_7_21==9 replace q9_7_21 = 0 if q9_7_21==2 bys mid mcep8: egen rm = mode(q9_7_21), maxmode lab var rm "mig sends money to hh? (mig's account)" * q9_7_241 to q9_7_245 identify if mig sends goods (clothing, food, hh appliances, electric apppliances, vehicles) to hh. replace q9_7_241 = . if q9_7_241==9 | q9_7_241==2 replace q9_7_242 = . if q9_7_242==9 | q9_7_242==2 replace q9_7_243 = . if q9_7_243==9 | q9_7_243==2 replace q9_7_244 = . if q9_7_244==9 | q9_7_244==2 replace q9_7_245 = . if q9_7_245==9 | q9_7_245==2 egen q9_7_24 = rsum(q9_7_241 q9_7_242 q9_7_243 q9_7_244 q9_7_245) bys mid mcep8: egen rg = mode(q9_7_24), max replace rg = 1 if rg>=1 lab var rg "mig sends goods to hh (mig's account)?" gen rmg = 1 if rm==1 | rg==1 replace rmg = 0 if rm==0 & rg==0 lab var rmg "mig sends money or goods to hh (mig's account)?" bys mid mcep8: keep if _n==1 keep mid mcep8 nrpid rm rg rmg sort nrpid save "Temp/mremit94t.dta", replace * Then, merge using nrpid (or hhid94)