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

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


From   "Herve STOLOWY" <stolowy@hec.fr>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: "tabstat" with "by" and content of columns
Date   Sun, 18 Sep 2005 19:01:37 +0200

Dear Scott:

I tried both solutions and it works. I prefer the second one (with tabstat, tabstatmat and matrix) because I get the total of the four categories, which is not the case with statsmat and xpose.

I thank you very much for your help.

Best regards

Hervé

***********************************************************
Professeur/Professor
Coordinateur du Département/Head of Department
HEC Paris
Département Comptabilité Contrôle de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
stolowy@hec.fr
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> smerryman@kc.rr.com 09/18/05 5:50 PM >>>

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Herve STOLOWY
> Sent: Sunday, September 18, 2005 9:00 AM
> To: statalist@hsphsun2.harvard.edu
> 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/


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