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" <[email protected]>
To   <[email protected]>
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
[email protected]
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> [email protected] 09/18/05 5:50 PM >>>

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


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