Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Grouped vars with different summary measures in one table


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Grouped vars with different summary measures in one table
Date   Mon, 17 Dec 2007 14:19:10 +0100

Stefan Gawrich wrote:

I often have to report different summary measures of different vars by
group-level in one table. For example I'd like to display the proportion
of
overweight pre-school children (mean of dummy-var var1), the number of
cases
(sum of counting-var var2) and the median score of a test (p50 of var3)
by
city: 

    city     | overweight  cases  score  
  Frankfurt  |   0.12        77    53   
  Wiesbaden  |   0.11       112    68    
...

tabstat (one-by-one or with all vars and summary measures specified
simultaniously) give the results but one needs a lot of copy & paste to
a
spreadsheet to get it in shape. collapse is of course another solution
but
slow with big datasets and certainly a very big transformation just to
obtain some descriptive statistics.

If there's a solution already available I would be glad to know. I'm
thinking of a command where (as in collapse) summary measures can
individually be assigned to vars, like:  tabstat2 (mean) var1 (sum) var2
(p50) var3, by(group). 

--------------------------------------------------------------

Fred Wolfe pointed to the unofficial -fsum- command which may or may
not fulfill Stefan's needs.

I think the official -table- command does the job:

    . sysuse auto
    . table foreign, contents(freq mean mpg sum price p50 length)
    --------------------------------------------------------------
     Car type |       Freq.    mean(mpg)   sum(price)  med(length)
    ----------+---------------------------------------------------
     Domestic |          52      19.8269       315766          200
      Foreign |          22      24.7727       140463          170
    --------------------------------------------------------------

Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index