Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: AW: AW: save two-way tables as a dataset
From
Hewan Belay <[email protected]>
To
[email protected]
Subject
Re: st: AW: AW: save two-way tables as a dataset
Date
Fri, 4 Jun 2010 14:27:31 -0700 (PDT)
Dear Martin and Nick,
Thanks for your response. It appears to be the case that there is no way to make the output of a two-way table directly appear in a dataset *the very way* it appears as stata output, without writing additional command lines to bring it into the desired shape.
There are various reasons I had wanted this to be the case:
1) To calculate the kind of ratios I described--Martin, you're right this can still, be done with the additional command lines such as what you proposed below
2) to take the table (if it could be made to look like the way the stata output of the twoway table does) with the resulting ratios and immediately (without much fuss) bring it into some word processing application--for that Martin your solution wouldn't work
Nick, -contract- works for counts/frequencies but not for means. -collapse- would do, but I would need to redo my many (many!) command lines which use -table-.
So I'll go with Martin's suggestion to the person who asked about this w.r.t. one-way tables, i.e. add the -replace- option to -table-, and then do further manipulations a la Martin's below example. A pity though, it would have been wonderful if there were a way to make stata simply go ahead and put a table into a datset the very way it appears on the stata output window...
Best,
Hewan
--- On Thu, 6/3/10, Martin Weiss <[email protected]> wrote:
> From: Martin Weiss <[email protected]>
> Subject: st: AW: AW: save two-way tables as a dataset
> To: [email protected]
> Date: Thursday, June 3, 2010, 3:45 PM
>
> <>
>
> 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
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]]
> Im Auftrag von Martin Weiss
> Gesendet: Donnerstag, 3. Juni 2010 17:36
> An: [email protected]
> Betreff: st: AW: save two-way tables as a dataset
>
>
> <>
>
>
> 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).
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]]
> Im Auftrag von Hewan Belay
> Gesendet: Donnerstag, 3. Juni 2010 17:17
> An: Stata List
> Betreff: st: save two-way tables as a dataset
>
> Dear Statalist,
>
> 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.
>
> Thanks for any help on this,
> Hewan
>
>
>
> *
> * 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/
>
>
> *
> * 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/
>
>
> *
> * 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/
>
*
* 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/