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: RE: Request for advice on simple summary tables for LaTeX


From   Dorothy Bridges <[email protected]>
To   [email protected]
Subject   Re: st: RE: Request for advice on simple summary tables for LaTeX
Date   Mon, 12 Mar 2012 20:11:34 -0700

Dear all: Please disregard the below inquiry.  For some reason,
applying the esttab "label" option didn't work with Martin's example,
but it did work with my own data (?) -- my apologies --

On Mon, Mar 12, 2012 at 7:55 PM, Dorothy Bridges <[email protected]> wrote:
> Dear all,
>
> I'm reviving an old thread here to ask about tabstat, variable labels,
> and LaTeX.  My question was asked below: what is the easiest way to
> write a summary-statistics table with variable labels (a la fsum) to
> tex?  Martin suggested using estpost and esttab, but (certainly
> because of my own ignorance) I do not see how that solution allows for
> using variable labels.
>
> Thank you in advance for your help.
>
> On Fri, Oct 30, 2009 at 2:16 PM, Venable <[email protected]> wrote:
>> 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 <[email protected]> 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: [email protected]
>>> [mailto:[email protected]] On Behalf Of Venable
>>> Sent: Freitag, 30. Oktober 2009 20:22
>>> To: [email protected]
>>> 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/

*
*   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