Hello Statalisters,
I downloaded the following code made publicly available by Olken, Onishi & Wong, (2014) from https://economics.mit.edu/faculty/bolken/data, and am using it in Stata 14. I am not too familiar with loops in Stata, although it seems to me that it is possible to use a loop which would allow me to run the same commands for Wave II and Wave III data and save them in two separate tables. It would be great if anyone could suggest a way to put this code into a loop.
Thanks,
Monzur
Reference: Olken, B. A., Onishi, J., & Wong, S. (2014). Should Aid Reward Performance? Evidence from a field experiment on health and education in Indonesia. American Economic Journal: Applied Economics, 6(4), 1-34.
I downloaded the following code made publicly available by Olken, Onishi & Wong, (2014) from https://economics.mit.edu/faculty/bolken/data, and am using it in Stata 14. I am not too familiar with loops in Stata, although it seems to me that it is possible to use a loop which would allow me to run the same commands for Wave II and Wave III data and save them in two separate tables. It would be great if anyone could suggest a way to put this code into a loop.
Thanks,
Monzur
Reference: Olken, B. A., Onishi, J., & Wong, S. (2014). Should Aid Reward Performance? Evidence from a field experiment on health and education in Indonesia. American Economic Journal: Applied Economics, 6(4), 1-34.
Code:
cd ../ cd "Wave II" use table_1_2_vars_w2_with_w1controls, clear foreach q in gross_SD_enroll_kec gross_SMP_enroll_kec{ bys Location_ID: egen `q'_w1_temp = max(`q'_w1) if obs_type == 10 replace `q'_w1 = `q'_w1_temp if obs_type == 10 drop `q'_w1_temp } save table_1_2_w2, replace cd ../ cd "Wave III" use table_1_2_vars_w3_with_w1controls, clear foreach q in gross_SD_enroll_kec gross_SMP_enroll_kec{ bys Location_ID: egen `q'_w1_temp = max(`q'_w1) if obs_type == 10 replace `q'_w1 = `q'_w1_temp if obs_type == 10 drop `q'_w1_temp } save table_1_2_w3, replace
Comment