Include stats(N, fmt(%18.0g)
into your esttab code.
Edit: Sorry, I did not see that you specify N
to be into a multicolumn before. The following does the trick, and includes something more in additional, i.e. if you want R2 to be decimal aligned again with 3 decimal points after N (using siunitx, see below):
stats(N r2_p, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{S}{@}") labels(`"Observations"' `"Pseudo \(R^{2}\)"'))
I should add that I highly recommend switching to siunitx for decimal alignment. Have a look at Mico's answer:
And my two follow up questions:
Furthermore, I recommend using esttab with the fragment option (just include f
in your esttab code). The table generated by esttab is then the pure table content, without headers and notes. I find when tables get a bit more complicated, esttab breaks them. You can avoid that with the fragment option.
When using the fragment option, include the following to your preamble:
\newcommand{\sym}[1]{\rlap{$#1$}} % Thanks to David Carlisle
\let\estinput=\input% define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% ********************************************************************
% Custom subcaptions
% ********************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
\vspace{-1.9ex}
\captionsetup{justification=justified,font=footnotesize}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}
\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}
% Add significance note with \starnote
\newcommand{\starnote}{\figtext{\sym{*} p < 0.1, \sym{**} p < 0.05, \sym{***} p < 0.01. Standard errors in parentheses.}}
% ********************************************************************
% siunitx customization
% ********************************************************************
\usepackage{siunitx} % centering in tables
\sisetup{
detect-mode,
tight-spacing = true,
group-digits = false ,
input-signs = ,
input-symbols = ( ) [ ] - + *,
input-open-uncertainty = ,
input-close-uncertainty = ,
table-align-text-post = false
}
This creates two wrappers for esttab generated tables. \estwide
uses tabular*
and fills the table to the textwidth, \estauto
uses tabular
and uses the "standard" table width (i.e. width adjusted to your content).
The custom subcaptions are to include simple notes below the table using the caption
package. You could then include a table as follows:
\begin{table}
\caption{A really cool table} % The heading
\estwide{table.tex}{2}{S[table-format=4.4]} % Include the table in the first bracket, the second bracket specifies the number of "data" columns and the third is for alignment (here using siunitx). The "4.4" specifies the decimals before and after the dot.
% \estauto{table.tex}{2}{S[table-format=4.4]}
\starnote % add description for significance stars
\figtext{\emph{Dependent Variable:} My dependent variable is cool}
\fignote{Omitted groups: \emph{Employment:} Some dummies}
\label{table}
\end{table}
It's not clear that there is really an issue to be solved, it is only an issue for tables if you think there is an issue about tables. Most of the points that you raise could also be made about "paragraphs" or "lists", at some point you have to have some structural information as well as words.
It is easy to have an environment that defaults the column spec, consider for example the amsmath matrix
which is more or less just array
with a default supplied preamble of *{20}{c}
so you could define
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}}{%
\end{tabular}}
which makes the column specifications optional, defaulting to all centred. Unlike matrices though where a global default is commonly useful, in my experience a global table default is almost never useful, tables usually have varied column types, some textual, some numeric to be aligned on decimal points, etc. However if in a particular document you have a lot of tables all taking the same form you could use a definition as above, replacing *{50}{c}
by say >{\bfseries}l *{2}{D..{3.2}} p{3cm}
if all your tables have a bold left aligned column, two numeric columns and a final column of note paragraphs.
It's hard to guess how you could automate rules in general, If you always want a top and bottom rule you could change your definition to
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}\toprule}{%
\\\bottomrule\end{tabular}}
But the position of \midrule
is rather like the position of words and numbers in the table, effectively it's data that must be entered in each case. Perhaps you only want \midrule
after the heading in which case you could use
\newcommand\endhead{\\\midrule}
so your tables would then look like
\begin{mytab}
\hd{type}&\hd{A}&\hd{B}&\hd{Notes}\endhead
zzz&1.2&3.4& zz zz zzzzz\\
zzz&1.2&3.4& zz zz zzzzz\\
\end{tab}
Using a heading command \hd
that could be defined as
\newcommand\hd[1]{%
\multicolumn{1}{c}{\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}
To give bold, centred, potentially multi-line table headings. Color could be added to this command as well if you want coloured tables, there is no need for explicit colours in the table.
Best Answer
The excellent siunitx package would make things a bit easier.
The additional grouping with curly braces lets the concerned cell content appear as simple text and not as a number to be parsed. Details for customization in the package manual.