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

st: how to recover data saved with tabstat ?


From   Giulio Rizzoli <giulio.rizzoli@unipd.it>
To   statalist@hsphsun2.harvard.edu
Subject   st: how to recover data saved with tabstat ?
Date   Sat, 11 Dec 2004 13:19:24 +0100

Can someone help me with this easy question I was not able to solve.
I have two numeric variables (see summarize) and I calculate with tabstat
a proportion of dead according to quarters (from 1 to 10) of sequential years .
**************************************************************
. summ op_quart dead

Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
op_quart | 2207 5.556411 2.905487 1 10
dead | 2207 .0475759 .2129154 0 1


. tabstat op_quart dead , by(op_quart) stat(mean) save

Summary statistics: mean
by categories of: op_quart

op_quart | op_quart dead
---------+--------------------
1 | 1 .0787037
2 | 2 .0454545
3 | 3 .0643564
4 | 4 .0452261
5 | 5 .0223214
6 | 6 .0547945
7 | 7 .0379147
8 | 8 .04329
9 | 9 .0394737
10 | 10 .0468085
---------+--------------------
Total | 5.556411 .0475759
------------------------------

Table stat saves the results in r()
. return list

macros:
r(name10) : "10"
r(name9) : "9"
r(name8) : "8"
r(name7) : "7"
r(name6) : "6"
r(name5) : "5"
r(name4) : "4"
r(name3) : "3"
r(name2) : "2"
r(name1) : "1"

matrices:
r(Stat10) : 1 x 2
r(Stat9) : 1 x 2
r(Stat8) : 1 x 2
r(Stat7) : 1 x 2
r(Stat6) : 1 x 2
r(Stat5) : 1 x 2
r(Stat4) : 1 x 2
r(Stat3) : 1 x 2
r(Stat2) : 1 x 2
r(Stat1) : 1 x 2
r(StatTot) : 1 x 2

I want to copy the saved results in a new variable called proportion
gen proportion=.
(2207 missing values generated)

. replace proportion= `"10"' if op_quart==10
type mismatch
r(109);
****************************************************************************************************
I can't figure out how to recover the proportions (means), saved from a simple tabstat procedure and place them in the new variable "proportion".
I was expecting each result to be saved in the local macros "10" to "1"
but my interpretation is not correct, how should be done ?
Also How can I read ( in a matrix I suppose) the entire matrices of results r(Stat10) -r(StatTot)
I can't find a clue in the manuals !
Many thanks
Giulio Rizzoli Padova Italy

Giulio Rizzoli MD FETCS
Cardiochirurgia Padova
tel. 049 821-2408
fax 049 821-2409
e-mail giulio.rizzoli@unipd.it
web: http.//web.tiscali.it/grizzoli

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