I have the following issue: I'm exporting regression output from Stata and inputing into my LaTex document. My goal is to write headers and footers in latex and simply input the raw "table-data" with \input{}
. I use tabularx and align at the decimal. But I also want to print the number of observations in my table. These are round about 250-1500, they are aligned at the decimal so to speak, but since they have no decimal they throw of the visual effect of decimal alignment. I would rather instead center them in the column. I know this is possible by putting a \mulitcolumn{}{}{}
environment around it, but this would require manual changes every time I update the table that is created by Stata. I'm looking for a scalable solution. Is it possible to somehow define a columntype that is flexible enough to align numbers between {-1,1} at the decimal, and center numbers without decimals.
Here is an example of my table:
\newcolumntype{Y}{D..{1.5}}
\newcolumntype{L}[1]{>{\raggedright}p{#1}}
\begin{table}
\begin{minipage}{\textwidth}
{\footnotesize
\lipsum[5]}
\end{minipage}
\begin{tabularx}{\textwidth}{L{3.8cm} @{\extracolsep{\fill}}*{2}{Y}}
\toprule
\multicolumn{1}{l}{} & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} \\
\midrule
\input{tab}
\midrule
Firm FE & \multicolumn{1}{c}{X}& \multicolumn{1}{c}{X} \\
Time FE & \multicolumn{1}{c}{X}& \multicolumn{1}{c}{X} \\
\bottomrule
\end{tabularx}
\end{table}
where the file tab.tex is saved directly from Stata and contains the following code:
Variable 1 & 0.012 & -0.542 \\
Variable 2 & 0.523 & 0.235 \\
\midrule
No. of Obs. & 1459 & 255 \\