Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: saving -tabstatmat- output as matrix/data


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: saving -tabstatmat- output as matrix/data
Date   Fri, 24 Jun 2011 17:40:55 +0100

This is going a very long way round, like going to Toronto via Chicago. You want to push stuff through -tabstat- so that it can then be pushed through -tabstatmat- (user-written, from SSC; you should explain this according to Statalist advice) so that you can then .... 

What is the need? To get from a dataset to a new dataset of means? Use -collapse- and get there in one step. 

Nick 
n.j.cox@durham.ac.uk 

Enayetur Raheem
 
I was searching for a way to save -tabstatmat- output as a matrix so
that I can transform it as data. Any suggestion would be much
appreciated. 
 
Lets consider the Auto data:

. sysuse auto, clear
 
. tabstat price, by(foreign) stat(mean) save
 
Summary for variables: price
     by categories of: foreign (Car type)
 
 foreign |      mean
---------+----------
Domestic |  6072.423
 Foreign |  6384.682
---------+----------
   Total |  6165.257
--------------------

What I want to achieve is to save the following output to a matrix (or
any other way to make it the data) 
 
. tabstatmat price
 
price[3,1]
                   price
Domestic:mean  6072.4231
 Foreign:mean  6384.6818
   Total:mean  6165.2568


Thanks in advance. 


Enayetur Raheem
Data Analyst
Epidemiology Department
Windsor Essex County Health Unit
1005 Ouellette Avenue
Windsor, ON, N9A 4J8


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