Statalist


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

Re: st: RE: Request for advice on simple summary tables for LaTeX


From   Venable <venablito@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Request for advice on simple summary tables for LaTeX
Date   Fri, 30 Oct 2009 17:16:44 -0400

Dear Martin,

Thank you very much for the suggestion and for your helpful example.
That is indeed a fantastic solution. I have been a fan of estout for a
long time but did not know it had this capacity.

It even has a booktabs option!

On Fri, Oct 30, 2009 at 3:48 PM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
> *******
> sysuse auto, clear
> estpost tabstat price mpg weight, /*
>  */  statistics( mean p25 median p75 ) /*
>  */  columns(variables)
> esttab using myfile.tex,  /*
>  */ cells("price mpg weight") /*
>  */  replace nonum noobs
> *******
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Venable
> Sent: Freitag, 30. Oktober 2009 20:22
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Request for advice on simple summary tables for LaTeX
>
> Dear Statalisters,
>
> I have been experimenting with a few different methods for creating
> tables of summary statistics in LaTeX. For example, I would like to
> present the mean, 25th percentile, median and 75th percentiles of the
> variables price, mpg and weight in the auto.dta dataset. There are a
> number of nice alternatives in Stata but I am having some trouble
> getting any of these to do exactly what I would like.
>
>
> The simplest option seems to be -latabstat-, as in
> latabstat price mpg weight, ///
>        columns(statistics) statistics(mean p25 p50 p75) ///
>        cap(Summary Statistics) clabel(summary-statistics) ///
>        tf(summary-statistics) replace
>
> This is very easy to implement and produces nice-looking output, but
> as far as I can tell it is not possible to use variable labels. Is
> this correct?
>
>
> I very much like the look of the tables created by -tabout-, for
> example in the nice tutorial:
> http://www.ianwatson.com.au/stata/tabout_tutorial.pdf
> The tables in this tutorial look great, in particular the spacing of
> the horizontal lines. However, I am finding it difficult to figure out
> whether -tabout- is the right option for simple summary tables - it
> seems to be built for more complicated tasks.
>
>
> -sutex- is also very easy but appears to be limited to just a few
> statistics (mean, min, max).
>
>
> Finally, I wrote something myself to summarize, extract the r()
> information to a Stata matrix, and then convert that matrix to a LaTeX
> table using the -outtable- command. For example,
>
> cap program drop summaryrow
> program summaryrow
>        args VarToSum
>        matrix `VarToSum'=J(1,4,.)
>        summ `VarToSum', detail
>        local j = 1
>        local statistics_list mean p25 p50 p75
>        foreach statistic of local statistics_list {
>                matrix `VarToSum'[1,`j']= `r(`statistic')'
>                local j = `j'+1
>        }
>        matrix colnames `VarToSum' = `statistics_list'
>        local myrowname: variable label `VarToSum'
>        matrix rownames `VarToSum' = `myrowname'
> end
> summaryrow price
> summaryrow mpg
> summaryrow weight
> matrix SummaryTable = price \ mpg \ weight
> outtable using SummaryTable, ///
>        mat(SummaryTable ) ///
>        nobox center f(%9.0f) ///
>        caption("Summary Statistics") clabel(summary-table) ///
>        replace
>
> This does allow me to use variable labels but is a bit hacked together
> given my poor programming skills. Also, it would be nice to tweak the
> spacing of the horizontal lines, which is probably possible but is a
> bit beyond me.
>
>
>
> In any event, I would really appreciate some guidance on how to
> combine the best of these methods. I apologize if this has been
> covered before or if the answer is obvious. I did some searching of
> the Statalist archives and looked through the help files of the
> different commands but was not able to figure this out. This is
> probably the result of my own deficiencies rather than any problem of
> the commands themselves.
>
> Thanks very much for any help you can provide.
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index