I have a loop that generates 24 regressions: 12 using an all boys sample, and 12 using an all girls sample. I'd like to store these regressions using eststo in a way that the boys sample regressions are called "boy1, boy2, ..., boy12", and the girls sample regression are called "girl1, girl2, ..., girl12".
I've tried so many local macro attemps but they are seem to fail. How can I do this? Below is my code right now, calling the estimates r1 to r24.
I've tried so many local macro attemps but they are seem to fail. How can I do this? Below is my code right now, calling the estimates r1 to r24.
Code:
qui eststo clear
local i 1
foreach sample in 1 0{
foreach sex in boys girls{
forv st = 1(1)2{
preserve
keep if boy == `sample'
eststo r`=`i'': reg delta_`sex'`st' $controls1, cluster($cluster_vars)
estadd ysumm
estadd local Mean = string(round(e(ymean), 0.01), "%9.2f")
estadd local fe Yes
local i = `i' + 1
eststo r`=`i'': reg delta_`sex'`st' $controls2, cluster($cluster_vars)
estadd ysumm
estadd local Mean = string(round(e(ymean), 0.01), "%9.2f")
estadd local fe Yes
local i = `i' + 1
eststo r`=`i'': reg delta_`sex'`st' $controls3 cluster($cluster_vars)
estadd ysumm
estadd local Mean = string(round(e(ymean), 0.01), "%9.2f")
estadd local fe Yes
local i = `i' + 1
restore
}
}
}

Comment