Take the 2-minute tour ×
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.

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. –  cgnieder Mar 22 '12 at 14:44
add comment

1 Answer

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

\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}
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
show 2 more comments

Your Answer

 
discard

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.