Customizing tables in Stata

2019-09-06 17:27发布

问题:

Using Stata14 on windows, I am wondering how to build customized tables from several regression results. Here is an example. We have

reg y, x1
predict resid1, residuals
summarize resid1

Which gives:

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      resid1 |  5,708,529    4.83e-11    .7039736  -3.057633   3.256382

And run another regrerssion and similarly obtain the residuals:

reg y, x2
predict resid2, residuals

I would like to create a table which has the two standard deviations of the two residuals, and optimally output it to latex. I am familiar with the esttab and estout commands for outputting regression results to latex, but these do not work for customized tables as in the above example.

回答1:

You need to use estpost. This should get you started.

sysuse auto, clear
regress price weight
predict error1, residuals
regress price trunk
predict error2, residuals

eststo clear
estpost summarize error1 error2
eststo
esttab, cells("count mean sd min max") noobs nonum
esttab using so.tex, cells("count mean sd min max") noobs nonum replace

More here.