Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: "tabstat" with "by" and content of columns


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: "tabstat" with "by" and content of columns
Date   Sun, 18 Sep 2005 10:50:07 -0500

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Herve STOLOWY
> Sent: Sunday, September 18, 2005 9:00 AM
> To: [email protected]
> Subject: st: "tabstat" with "by" and content of columns
 
<snip>
 
> I would like to get the 4 categories in columns and the stats in rows.
> 
> None of the above codes provide the display I am looking for. (The four
> caterogies of ind are always displayed in rows).
> 
> Do you think it is possible to get it with tabstat? If not, is there
> another possibility?
> 

Yes, if you transpose the results matrix or you could use -statsmat- with
the xpose option.  Examples below: 


. sysuse auto,clear
(1978 Automobile Data)

. statsmat mpg, by(rep) stat(sum mean median p25 p75 min max) xpose f(%9.5g)

             1       2       3       4       5
   sum      42     153     583     390     301
  mean      21  19.125  19.433  21.667  27.364
median      21      18      19    22.5      30
   p25      18    16.5      17      18      18
   p75      24      23      21      25      35
   min      18      14      12      14      17
   max      24      24      29      30      41

. qui tabstat mpg, by(rep) stat(sum mean median p25 p75 min max) col(stat)
f(%9.5g) save

. qui tabstatmat B

. matrix B = B'

. matrix list B, f(%9.5g)

B[7,6]
           1       2       3       4       5   Total
 sum      42     153     583     390     301    1469
mean      21  19.125  19.433  21.667  27.364   21.29
 p50      21      18      19    22.5      30      20
 p25      18    16.5      17      18      18      18
 p75      24      23      21      25      35      24
 min      18      14      12      14      17      12
 max      24      24      29      30      41      41


Scott



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index