i trying run program inside loop, getting
-break-- r(1);
here script:
clear forvalues i=1/5{ sysuse auto if rep78==`i' capture program drop testpro program define testpro,eclass preserve tabstat price mpg headroom,stat(mean) save mat avg=r(stattotal) ereturn post avg restore end } --break-- r(1); end of do-file --break-- r(1);
any in regard highly appreciated.
there several issues here. one, can't sysuse
if
clause, unlike use
.
there's no need re-define program each iteration of loop. define it, loop.
i not sure why need program, matter of taste or perhaps merely pedagogical example.
the command estadd
in code below part of estout
suite scc.
clear capture program drop testpro program define testpro, eclass tabstat price mpg headroom, stat(mean) save quietly estadd matrix avg = r(stattotal), replace end forvalues i=1/5 { sysuse auto, clear keep if rep78==`i' testpro matrix list e(avg) }
Comments
Post a Comment