2
votes

Is there any way to save and reload data in between an eststo command and an esttab?

What I would love is something like the following:

eststo: quietly reg a b
estsave using foo.est, replace

***

*Some other File
estload using foo.est
esttab foo.tex

Any other alternatives that let me play with the way I output regressions by trial and error (without having to re-run them and having to be at an interactive prompt) would be enormously helpful.

2
If you found my answer helpful, please consider up-voting it with the upper arrow and accepting it using the check-mark.user8682794

2 Answers

2
votes

Why do you need to put it to disk?

The (prefix) command eststo stores the results in memory until you close the file, and unless specified names each estimate consecutively (eststo1, eststo2 etc.). You can re-program and re-run only part of the do file.

Alternatively, you could create all estimates in a do and call it from a secondary do:

/* .do for make tables */
do makeEstimates.do
esttab ...

Elsewhere you program makeEstimates.do:

/* .do to make estimates */
quietly regress a b
estout ab

You can run once, then comment out the do makeEstimates.do line to just work on estout if you do not change them.

0
votes

You can store estimates on disk with the estimates save command:

sysuse auto, clear

quietly regress price mpg
estimates save foo1

quietly regress price trunk
estimates save foo2

quietly regress price weight
estimates save foo3

The above code snippet creates 3 files in your current working directory containing the estimates:

foo1.ster
foo2.ster
foo3.ster

You can then reload these and use them with esttab non-interactively and in any way you like with the estimates use command:

estimates use foo2
esttab .

----------------------------
                      (1)   
                    price   
----------------------------
trunk               216.7** 
                   (2.81)   

_cons              3183.5** 
                   (2.87)   
----------------------------
N                      74   
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

estimates use foo1
esttab .

----------------------------
                      (1)   
                    price   
----------------------------
mpg                -238.9***
                  (-4.50)   

_cons             11253.1***
                   (9.61)   
----------------------------
N                      74   
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

estimates use foo3
esttab .

----------------------------
                      (1)   
                    price   
----------------------------
weight              2.044***
                   (5.42)   

_cons              -6.707   
                  (-0.01)   
----------------------------
N                      74   
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001