Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: estout2 and latex tables


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   re: st: estout2 and latex tables
Date   Mon, 28 May 2012 05:48:58 -0400

<>
Chris said

I am using Stata IC 10.0 for macintosh, and have been looking for a
way to export a series of regression model results directly to a
single latex table.  I've traditionally imported from ASCII to excel,
formatted the tables there, and used excel2latex to convert the tables
to latex.  However, this is a time consuming process (particularly
with repect to dealing with bracketted standard error terms) and it
would save a lot of hassle if I could generate latex tables directly.

I've tried using both the estout and outreg2 routines, but neither
seem to work.  Specifically, the "tex" option does not seem to ever do
anything, and I end up with a txt file with tab delimiters (instead of
'&' delimiters) and no line breaks.  (Since I am estimating multiple
models, in the case of outreg2 I have added the "tex" option after the
last regression, which I take to be the meaning for the following help
file instructions: "outreg2 cannot append TeX format tables to one
another, so regressions must be appended in ASCII form until the last
regression, which is appended with the tex option.")

My code is essentially as follows:

regress y x if z==1
outreg2 x using myfile, stats(coef se) replace

regress y x if z==2
outreg2 x using myfile, stats(coef se) append

regress y x if z==3
outreg2 x using myfile, stats(coef se) tex append

(I have also tried this using the tex option within each outreg2
command.)  But the resulting "myfile" just contains tab delimited
output.  Trying estout I run into the same problem.

Is anyone able to confirm that these routines are able to generate
tables that can be imported directly into latex with Stata 10?  And if
so, is there anything wrong in what I am doing?  Any suggestions or
recommended reading is greatly appreciated.


I know nothing about outreg2, but with respect to Ben Jann's estout, you should be able to run any of the examples at the estout website
and produce LaTeX output files with Stata 10, no problem. estout was written for Stata 8.2, and works fine in any later version of Stata. I use
it to produce tex tables on Mac OS X every day with no problem. E.g.,

	qui estout c`i'US gc`i'US c`i'UK gc`i'UK    ///
	using `results'`uncert_basis'`i'.tex, cells(b(star fmt(%10.3f)) se(par)) delim("&") ///
	drop(_cons _I* o.* X*) style(tex) collabels(, none) stats(N upval linkpval, fmt(%9.0fc %5.3fc %5.3fc  )  ///
	labels("Firm-years" "Firm deviations p-value" "Link test p-value" )) eqlabels(none) replace ///
	mlabels("US-Tobit" "US-GLM" "UK-Tobit"  "UK-GLM") ///
	prehead("\begin{table}[tbhp] \caption{`want`i'' deviations based on `uncert_basis'} \centering \begin{tabular}{lrrrrrrrr}" \hline \hline) ///
	posthead(\hline) prefoot(\hline) postfoot(\hline \hline "\end{tabular} \end{table} \pagebreak") ///
	varwidth(30)  starlevels(* 0.1 ** 0.05 *** 0.01) ///
	varlabel(L.HHI "Sales Concentration" L.divers "Sales Diversification" L.HHI1 "Domestic Sales Only" L.multi "Foreign Productive Assets" ///
	L.uncert "Panel Data Shocks" L.firmAR "Firm AR Shocks" ///
	L.uncert2 "Panel Data Volatility" L.firmAR2 "FirmAR Volatility" logLabour "Log(Employment)" ///
	L.Cash2TA "Lag Cash/Total Assets" L.D2TA "Lag Total Debt/Total Assets")

Just by mentioning .tex in the using file name, it produces a LaTeX fragment that can be \input{ } into your LaTeX document.

By the way there is no excuse for using Stata 10.0; Stata 10.1 is a free upgrade, and has been available since August 2008. As it contains many new features as well as bugfixes you really should upgrade.

Kit


Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                             An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
  An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index