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

st: re: recovering results from tabstat


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: recovering results from tabstat
Date   Sun, 12 Dec 2004 09:19:20 -0500

Guilio said
>gen group2 = .
>gen proportion2 = .
>
>qui tab trunk
>local N = r(r)
>
>tabstat trunk foreign , by(trunk) stat(mean) save
>
>forv i = 1(1)`N' {
>mat M = r(Stat`i')
>scalar name = M[1,1]
>scalar prop = M[1,2]
>qui replace group2 = scalar(name) in `i'
>qui replace proportion2 = scalar(prop) in `i'
>}
>
>l group* proportion* if group in 1/18

Many thanks to Orsini Coviello and Baum for their rapid response and many
solutions.
Orsini's solution recorded above was the one I was really interested in: It
shows how to read in useful variables the results saved in r( ) by tab
program, a useful piece of information that is missing in the help of the
return command.
Thank you all again
Giulio Rizzoli

I find the way in which tabstat stores its results to be excessively cumbersome.
Another way is to avoid tabstat entirely and do it in two commands:

statsmat dead, stat(mean) by(year) mat(popstat)
svmat popstat, names(proportion)

An advantage of this strategy is that one could apply it to more than one statistic in the statsmat command.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

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