Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Hewan Belay <hewan_belay@yahoo.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
RE: st: AW: AW: save two-way tables as a dataset |

Date |
Sat, 5 Jun 2010 09:39:19 -0700 (PDT) |

Dear Martin, My goals are both (1) and (2) of my earlier email, i.e. both (1) to be able to do further manipulations e.g. the ratio calculation given as an example, and (2) to then take the whole thing, with the ratios, say, and bring it into txt or word. The command lines you did earlier to calculate ratios satisfy (1), but not (2) in the sense of retaining the row and col structure of the original stata output. The suggestion such as -tabout- satisfies (2) but not (1). I just tried -postfile-, it seems a bit involved so I will spend time learning how to use this command properly. Else, I will just go ahead and use -table...replace- as you initially recommended, followed by furhter commands to bring the tables into the desired row-column structure. Many thanks, Hewan --- On Fri, 6/4/10, Martin Weiss <martin.weiss1@gmx.de> wrote: > From: Martin Weiss <martin.weiss1@gmx.de> > Subject: RE: st: AW: AW: save two-way tables as a dataset > To: statalist@hsphsun2.harvard.edu > Date: Friday, June 4, 2010, 10:38 PM > > <> > > " 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..." > > > > To get the output _asis_ into a word processor, just -log- > it and open the > log file in your processor: > > *** > sysuse auto, clear > > //to log in an additional log > > log using mylog, name(newlog) replace > table rep78 foreign, c(mean headroom) row > > log close newlog > > //translate > translate mylog.smcl mylog.txt, replace > !start mylog.txt > *** > > Or copy and paste it with a right-click. Is your goal > really to have it in a > word-processor, or do you want to further process the > numbers in the > -table-? > > > On a different level, Stata cannot possibly cater to every > need that arises > in this area. -postfile- is sort of the last hope in such > cases, and it is > versatile enough for experienced users to get customized > solutions. But just > imagine what you are asking for: A Stata file that looks > exactly as the > -table-. How would, for instance, the second column be > formatted? As string > (to store "Car Type" and "Domestic") or as numeric, to > store the numbers in > the -table-? > > HTH > Martin > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] > On Behalf Of Hewan Belay > Sent: Freitag, 4. Juni 2010 23:28 > To: statalist@hsphsun2.harvard.edu > Subject: Re: st: AW: AW: save two-way tables as a dataset > > 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 <martin.weiss1@gmx.de> > wrote: > > > From: Martin Weiss <martin.weiss1@gmx.de> > > Subject: st: AW: AW: save two-way tables as a dataset > > To: statalist@hsphsun2.harvard.edu > > 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: owner-statalist@hsphsun2.harvard.edu > > [mailto:owner-statalist@hsphsun2.harvard.edu] > > Im Auftrag von Martin Weiss > > Gesendet: Donnerstag, 3. Juni 2010 17:36 > > An: statalist@hsphsun2.harvard.edu > > 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: owner-statalist@hsphsun2.harvard.edu > > [mailto:owner-statalist@hsphsun2.harvard.edu] > > 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/ > > > * > * 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/

**Follow-Ups**:**RE: st: AW: AW: save two-way tables as a dataset***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**References**:**RE: st: AW: AW: save two-way tables as a dataset***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**RE: st: RE: Calculate variances of subsamples** - Next by Date:
**Re: st: Another method of squaring an instrumental variable** - Previous by thread:
**RE: st: AW: AW: save two-way tables as a dataset** - Next by thread:
**RE: st: AW: AW: save two-way tables as a dataset** - Index(es):