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: AW: AW: save two-way tables as a dataset


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: AW: AW: save two-way tables as a dataset
Date   Thu, 3 Jun 2010 17:25:36 +0100

See also -contract- and -collapse-. 

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

Martin Weiss

BTW, the output from -table- still allows you to calculate a ratio where
appropriate:

*************
sysuse auto, clear
table rep78 foreign, contents(sum headroom ) row replace
list, sepby(rep78) noo
bys rep78 (foreign): gen ratio=table1[1]/table1[2] if _N==2
list, sepby(rep78) noo
*************

Martin Weiss


Where and how do you want to use/further process the results? 

You may want to look at Ian`s -ssc d tabout- (the ssc server may be down
at
the moment, just as Kit said last night). 

Hewan Belay

Back in 2009 there was a thread about how to save stata outputs, such as
outputs from the -table- command, as datasets: 
http://www.stata.com/statalist/archive/2009-04/msg00321.html .
This seems to work well only in one-way tables. For example, using the
example Martin gave back then, the following works well:

sysuse auto, clear
table rep78, contents(sum headroom ) row 
table rep78, contents(sum headroom ) row replace
list

However, I want to save a twoway table as a dataset. Notice that the
datset
doesn't look much like the output table:

table rep78 foreign, contents(sum headroom ) row 
table rep78 foreign, contents(sum headroom ) row replace
list

I want it to look more or less like the output table, that is, in this
case
a dataset with three variables--rep78, domestic, and foreign--for
example so
that I can create, say, an additional variable which gives me the ratio
of
domestic to foreign etc. Sure, I can do -reshape- and so forth, but it
would
be much cleaner if the output could be produced as a dataset without me
having to write several lines to get it to look like the output.


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