Graphics, Figures & TablesTable from Stata

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
bayesian23
Posts: 1
Joined: Wed May 03, 2023 10:40 am

Table from Stata

Post by bayesian23 »

Hello everyone,

I am running some regressions in Stata and use esttab to output the results into a Latex table.

I attach here the table that I get. But when I include that table into my tex document I get the following error:


table/mutual_fund_regression.tex

! Package array Error: Illegal pream-token (D): `c' used.

See the array package documentation for explanation.
Type H <return> for immediate help.
...

l.3 \begin{tabular}{l*{2}{D{.}{.}{-1}}}

?

Any ideas what the problem is here and how it can be fixed?

Many thanks in advance

Costas Antoniou
Attachments
mutual_fund_regression.tex
(1.07 KiB) Downloaded 141 times

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Table from Stata

Post by Stefan Kottwitz »

Hi Costas,

welcome to the forum!

The problem in this line \begin{tabular}{l*{2}{D{.}{.}{-1}}} is, that the D column type is not defined.

You can write, for example,\begin{tabular}{l*{2}{c}} instead.

Stefan
LaTeX.org admin
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Table from Stata

Post by rais »

or add \usepackage{dcolumn} to your preamble, then a "D" column is specified ;)

KR
Rainer
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Table from Stata

Post by Stefan Kottwitz »

Rainer's advice is the best, so our code runs as expected, and the numbers are aligned at the decimal point:

Code: Select all

\documentclass{article}
\usepackage{booktabs,dcolumn}
\begin{document}
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{2}{D{.}{.}{-1}}}
\hline\hline
                    &\multicolumn{2}{c}{Proportion Sold}        \\\cmidrule(lr){2-3}
                    &\multicolumn{1}{c}{(1)}         &\multicolumn{1}{c}{(2)}         \\
\hline
retpos              &       0.032\sym{***}&                     \\
                    &     (0.010)         &                     \\
[1em]
retneg              &       0.033\sym{**} &                     \\
                    &     (0.016)         &                     \\
[1em]
absret              &                     &       0.009         \\
                    &                     &     (0.010)         \\
\hline
Observations        & 1872832.000         & 1872832.000         \\
$R^2$               &       0.300         &       0.300         \\
Fund $\times$ Date F.E& F.E.  "Yes"         & F.E.  "Yes"         \\
Stock $\times$ year  F.E.& F.E.  "Yes"         & F.E.  "Yes"         \\
Stock $\times$ date F.E.&  F.E.  "No"         &                     \\
\hline\hline
\end{tabular}
}
\end{document}
table.png
table.png (33.28 KiB) Viewed 1803 times
You may notice that the text in the math columns doesn't look good. You can improve it, for example, by using \multicolumn at such cells, like
\multicolumn{1}{c}{F.E. "Yes"}.

Stefan
LaTeX.org admin
Post Reply