to speed up the code, I would like to export results to a file for every 10 regressions. Is it possible to do something like the following?
forvalues i = 1(1)20{
ppmlhdfe y ${varlist`i'}, absorb(year) cluster(year)
estimates store result`i'
if mod(`i', 10) == 0 {
outreg2 result* using "$outputdir1\results.csv"
est clear
}
}
In this pseudo-code, I mean that we save results for every 10 regressions, and clear the estimations in memory move on to the next 10 regressions. Is it possible in Stata?
You can certainly do things conditional on the loop index as in
I am not sure that I understand most of the rest of the code.
outreg2
is being asked to put stuff in exactly the same file; I don't useoutreg2
and have no idea what makes sense there. Similarly, on the face of it, you are storing estimates before you have them.What is the real saving here? Why execute regressions if you don't wnat to see the results?