TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a follow-up question to Estout and dcolumn: Overriding decimal alignment

In my case, using esttab, it centers the number of observations but it adds some decimals, for instance: Obersvations 3345.000, probably because I set se(3) or b(3) in the esttab command, which determine how many decimals are to be showed.

Any way to fix that?

esttab sex0 sex1 using men_women_aboradTTT.tex, stats(N,layout("\multicolumn{1{c}{@}") ///
    label("Observations")) se(3) b(3) ///
    noconstant label replace booktabs alignment(D{.}{.}{4,6}) ///
share|improve this question
It don't know about esttab but it seems to me that this answer might be useful for you. – clemens Mar 22 '12 at 14:44
up vote 2 down vote accepted

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



% Allow line breaks with \\ in specialcells

% ********************************************************************
% Custom subcaptions
% ********************************************************************
% Note/Source/Text after Tables
    \caption*{\hspace{6pt}\hangindent=1.5em #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
        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:

    \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}
share|improve this answer
I changed my original answer so that N is included in a multicolumn, as requested. If you are going to produce a lot of tables I highly recommend using the fragment option. – Jörg Mar 23 '12 at 12:23
Yep, it works for the decimals. With your suggestions I think I can maybe solve another problem as well. I have to get rid of the midrule that esttab puts before Observations and put another toprule. I will give it a try! – luciano Mar 23 '12 at 12:35
Yes, you can do that easily by changing the \estwide \estauto commands to your specification. – Jörg Mar 23 '12 at 12:40
I've created a lengthy post on my homepage that may help you further: jwe.cc/2012/03/stata-latex-tables-estout – Jörg Mar 23 '12 at 15:54
@luciano: please consider marking questions as answered. – Jörg Mar 28 '12 at 13:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.