Graphics, Figures & TablesIssue with Table created from Stata

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
nica
Posts: 1
Joined: Thu Feb 21, 2013 3:33 am

Issue with Table created from Stata

Post by nica »

I'm new to LaTeX, and I've been messing around with "eststo" and "esttab" to get regression results from Stata to LaTeX without having to mess with the code too much in the LaTeX file.

Unfortunately, I'm running into a weird problem: I want to set the table to 'wide' using "esttab" (putting the SEs next to the estimated coefficients, rather than below), but when I do, LaTeX seems unhappy with the dcolumn package (to align the decimal points). When I typeset, it gives me this error.

Code: Select all

117: Extra alignment tab has been changed to \cr. <template> \endtemplate
l.117 ... &\multicolumn{2}{c}{(1)}    &    \multicolumn{2}{c}{(2)} ... ?
Here's the Stata command (if that's helpful):

Code: Select all

esttab using /path/name.tex,  ///
	label title("Title") mtitles("M1" "M2") ///
	nodepvars se(3) b(3) ar2 r2 scalars(F) gaps replace wide booktabs alignment(D{.}{.}{-1})
And the start of the LaTeX output:

Code: Select all

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Title}
\begin{tabular}{l*{2}{cc}}
\toprule
                    &\multicolumn{2}{c}{(1)}           &\multicolumn{2}{c}{(2)}           \\
                    &\multicolumn{2}{c}{M1}  &\multicolumn{2}{c}{M2}  \\
\midrule
X1 &       0.657\sym{*}  &     (0.199)&       0.970\sym{*}  &     (0.298)\\
...

I originally suspected that changing the number of columns might have been the problem. I've looked into the dcolumn manual, but it didn't seem to help. Any suggestions would be much appreciated!
Last edited by localghost on Thu Feb 21, 2013 10:37 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Issue with Table created from Stata

Post by localghost »

Please prepare a self-contained and minimal example to give an adequate problem description. And perhaps you can avoid abbreviations like SE which nobody else than you knows.


Best regards and welcome to the board
Thorsten
sjhunk
Posts: 1
Joined: Wed Mar 13, 2013 6:28 pm

Re: Issue with Table created from Stata

Post by sjhunk »

same problem here, did you find a solution?

SE stands for standard errors.
short097
Posts: 1
Joined: Tue Mar 07, 2017 10:46 pm

Issue with Table created from Stata

Post by short097 »

I also just encountered this specific issue and now have the solution:

If you use the wide option you need to provide 2 column specifiers within the alignment() option.
See the description of the alignment option in help esttab:
"If the table contains multiple columns per model/equation, the alignment specification should define all columns. For example, if the wide option is specified, you could type alignment(cr) to, say, center the point estimates and right-align the t-statistics."

In the original question, for the Stata code you want something like this if you want both the point estimates and t-stats to be aligned using dcolumn: alignment(D{.}{.}{-1} D{.}{.}{-1})
Post Reply