Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to send -table- output to LaTeX table


From   Richard Herron <[email protected]>
To   [email protected]
Subject   Re: st: How to send -table- output to LaTeX table
Date   Wed, 9 May 2012 10:09:55 -0400

@Eric -- Thanks! -tabout- (SSC) is handy!

I found a solution with -estpost- (from -estout- on SSC) and -tabstat-.

This code replicates the two original -table- tables.

* begin code
sysuse auto, clear

* the oneway table
eststo clear
egen rep78_foreign = group(rep78 foreign)
estpost tabstat headroom trunk, ///
    by(rep78_foreign) nototal
eststo
esttab ., cells("headroom trunk") ///
    nonumber noobs label

* the twoway table
eststo clear
levelsof rep78, local(rep78s)
foreach x of local rep78s {
    estpost tabstat headroom trunk ///
        if (rep78 == `x'), by(foreign) ///
        statistics(mean) columns(statistics) ///
        nototal
    eststo
}
esttab _all, cells(mean) ///
    noobs nonumber label
* end code
Richard Herron


On Sun, May 6, 2012 at 10:46 PM, Eric Booth <[email protected]> wrote:
>
> <>
>
> Take a look at the latex options for -tabout- from SSC.  Another option is
> building this table in memory with -collapse- or some equivalent and then
> exporting the dataset with -texdoc- from SSC.
>
> - Eric
>
>
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> +979.845.6754
>
> On May 6, 2012, at 8:27 PM, Richard Herron wrote:
>
> > Is there a way to send -table- output to a LaTeX table? Or generate
> > similar output with I can typically find a solution using -estpost-
> > (from the -estout- package on SSC) combined with -tabstat- or
> > -tabulate-, but here I would like either a oneway table with
> > subdivisions of the sorting variable and several summary statistics
> > variables:
> >
> > . sysuse auto, clear
> > (1978 Automobile Data)
> >
> > . table foreign, by(rep78) c(mean headroom mean trunk)
> >
> > ------------------------------------------
> > Repair    |
> > Record    |
> > 1978 and  |
> > Car type  | mean(headroom)     mean(trunk)
> > ----------+-------------------------------
> > 1         |
> > Domestic |            1.8             8.5
> >  Foreign |
> > ----------+-------------------------------
> > 2         |
> > Domestic |            3.4          14.625
> >  Foreign |
> > ----------+-------------------------------
> > 3         |
> > Domestic |            3.2         15.5926
> >  Foreign |            2.7         12.3333
> > ----------+-------------------------------
> > 4         |
> > Domestic |            3.4         16.6667
> >  Foreign |            2.5         10.3333
> > ----------+-------------------------------
> > 5         |
> > Domestic |            2.3             9.5
> >  Foreign |            2.6         11.8889
> > ------------------------------------------
> >
> > Or a twoway table with several summary statistics (I guess for this
> > case I could do two -tabulate, summarize()- tables):
> >
> > . table foreign rep78, c(mean headroom mean trunk)
> >
> > -------------------------------------------------------
> >          |             Repair Record 1978
> > Car type |       1        2        3        4        5
> > ----------+--------------------------------------------
> > Domestic |     1.8      3.4      3.2      3.4      2.3
> >          |     8.5   14.625  15.5926  16.6667      9.5
> >          |
> >  Foreign |                       2.7      2.5      2.6
> >          |                   12.3333  10.3333  11.8889
> > -------------------------------------------------------
> >
> > I can't figure out how to generate these in -tabulate- or -tabstat-.
> > Should I manually generate these tables in LaTeX?
> >
> > Thanks!
> >
> > Richard Herron
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index