Dear Stata users.
I have 3 data sets and I would like to use a loop to run the same code on each of the 3 datasets. How can I do this?
The datasets are saved as follows:
13_LEZ_city_p (main var no2_tec)
1_LEZ_city_a (main var pmtech)
9_LEZ_city_lj (main var pmtech_2)
So the only thing that changes in these datasets are the vars no2_tec, pmtech, and pmtech_2
Thank you
JLi
I have 3 data sets and I would like to use a loop to run the same code on each of the 3 datasets. How can I do this?
The datasets are saved as follows:
13_LEZ_city_p (main var no2_tec)
1_LEZ_city_a (main var pmtech)
9_LEZ_city_lj (main var pmtech_2)
So the only thing that changes in these datasets are the vars no2_tec, pmtech, and pmtech_2
Code:
*** cd "$uni_pcdata" use 13_LEZ_city_p, clear eststo clear eststo: quietly probit no2_tec regul equip city_size age child health hhold i.city##i.year, cluster(idgroup) esttab, keep( regul equip city_size age child health hhold) star(* 0.1 ** 0.05 *** 0.01) pr2 se predict auct13 foreach X in regul equip city_size age child health hhold{ eststo: quietly probit no2_tec `X' i.city##i.year if auct13!=., cluster(idgroup) } save lez13, replace foreach num of numlist 1(1)28 { use lez13, clear keep if city==`num' psmatch2 no2_tec regul equip city_size age child health hhold i.year, out(pollutionN2) common sort idgroup year save pss`num', replace } use pss1, clear foreach num of numlist 1(1)28 { append using pss`num' } cd "$uni_pcdata" save city_psm, replace cd "$uni_pcdata" use 13_LEZ_city, clear merge m:1 idgroup using city_psm save city_psm_new, replace ***
JLi
Comment