Statalist


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

Re: st: three-way tables, exporting to tex


From   "Martin Weiss" <Martin.Weiss1@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: three-way tables, exporting to tex
Date   Fri, 20 Mar 2009 20:02:50 +0100

<>

Even w/o the line break, the error in the last line lingers on... I do not think that -esttab- takes a matrix, it only processes estimation results. I think -xml_tab- could do the trick...

HTH
Martin
-------- Original-Nachricht --------
> Datum: Fri, 20 Mar 2009 19:38:55 +0100
> Von: Johannes Geyer <JGeyer@diw.de>
> An: statalist@hsphsun2.harvard.edu
> Betreff: Re: st: three-way tables, exporting to tex

> owner-statalist@hsphsun2.harvard.edu schrieb am 20/03/2009 19:14:18:
> 
> > <>
> > 
> > Your last line -esttab matrix(a1)- gives me error 111:
> > "estimation result matrix(a1) not found"
> > 
> > Does the code run for you? Maybe I am missing a package?
> 
> No, you don't lack a package (I forgot to mention -estout/esttab-...) - I 
> think the option "stats" (in the loop) had an error caused by a line 
> break:
> 
> ************
> 
>          capture {
>                  qui tabstat grade if year == `u', by(cats) save stats(N 
> mean)
> ... 
> 
> }
> ************
> 
> and that was neither executed nor left an error message. I included the 
> capture block because for some years there are no observations.
> 
> But the code should work.
> 
> Johannes 
> 
> 
> > 
> > HTH
> > Martin
> > 
> > -------- Original-Nachricht --------
> > > Datum: Fri, 20 Mar 2009 19:00:44 +0100
> > > Von: Johannes Geyer <JGeyer@diw.de>
> > > An: statalist@hsphsun2.harvard.edu
> > > Betreff: Re: st: three-way tables, exporting to tex
> > 
> > > Here is one option (maybe not very elegant but does what you want):
> > > 
> > > ******************************************************
> > > clear
> > > webuse union
> > > table year union south, c(freq mean grade)
> > > ***
> > > 
> > > egen cats = group(south union)
> > > 
> > > * initialize matrix a1
> > > qui sum year
> > > qui tabstat grade if year == `r(min)', by(cats) save stats(N mean)
> > > qui tabstatmat a1
> > > matrix a1 = a1'
> > > 
> > > 
> > > qui sum year
> > > forvalues u = `=`r(min)'+1'/`r(max)' {
> > >         di "`u'"
> > >         capture {
> > >                 qui tabstat grade if year == `u', by(cats) save 
> stats(N 
> > > mean)
> > >                 qui tabstatmat a
> > >                 matrix a`u' = a'
> > >                 matrix a1 = a1\a`u'
> > >         }
> > > }
> > > 
> > > esttab matrix(a1)
> > > 
> > 
> ****************************************************************************************
> > > 
> > > Johannes
> > > 
> > > 
> > > ----------------------
> > > Johannes Geyer
> > > Deutsches Institut für Wirtschaftsforschung (DIW Berlin)
> > > German Institute for Economic Research 
> > > Department of Public Economics
> > > DIW Berlin
> > > Mohrenstraße 58
> > > 10117 Berlin
> > > Tel: +49-30-89789-258
> > > 
> > > owner-statalist@hsphsun2.harvard.edu schrieb am 20/03/2009 18:35:03:
> > > 
> > > > <>
> > > > 
> > > > -tabout- seems unable to do that. -table- can replace the current 
> > > > dataset, but what it leaves behind is not directly amenable to 
> > > > translation to tex. 
> > > > 
> > > > Seems you either have to -egen souunion=group(south union)- and then
> > > > work on a two-way table or look at custom solutions as in 
> > > > Baum(2009), chap. 10.3, http://www.stata-press.com/books/isp.html 
> ...
> > > > 
> > > > HTH
> > > > Martin
> > > > -------- Original-Nachricht --------
> > > > > Datum: Fri, 20 Mar 2009 17:45:47 +0100
> > > > > Von: Richard Ochmann <rochmann@diw.de>
> > > > > An: statalist@hsphsun2.harvard.edu
> > > > > Betreff: st: three-way tables, exporting to tex
> > > > 
> > > > > Hi,
> > > > > 
> > > > > how would you export a three-way table to a .tex document?
> > > > > 
> > > > > I would like to produce a summary table for a continuous variable 
> over
> > > 
> > > > > three categorical variables. Cells shall contain means as well as 
> > > > > frequencies.
> > > > > I found I can nicely do that with -table- (find my code below). 
> Now I 
> > > have
> > > > > a hard time exporting the resulting table to a .tex document that 
> I 
> > > can 
> > > > > further edit in LaTeX.
> > > > > I tried with user-written programs like -estout- and -tabout-. 
> While 
> > > > > -tabout- brings me close, I didnt figure out how to do a three-way
> 
> > > table 
> > > > > there.
> > > > > While this problem is certainly easily worked-around producing 
> > > separate 
> > > > > two-way tables conditioning on the third variable and somehow 
> > > combining 
> > > > > them, I would be happy to have a one-step solution here.
> > > > > 
> > > > > thanks for ideas!
> > > > > 
> > > > > Stata 10, WinXP
> > > > > 
> > > > > best, rich
> > > > > 
> > > > > ***
> > > > > clear
> > > > > webuse union
> > > > > table year union south, c(freq mean grade)
> > > > > ***
> > > > > 
> > > > > *
> > > > > *   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/
> > > > 
> > > > -- 
> > > > Martin Weiss
> > > > Hackersteigle 3
> > > > 72076 Tübingen
> > > > 00497071/793535
> > > > 00491784597218
> > > > 
> > > > Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal 
> geschützt?
> > > > Jetzt absichern: https://homebanking.gmx.net/?mc=mail@footer.hb
> > > > *
> > > > *   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/
> > 
> > -- 
> > Martin Weiss
> > Hackersteigle 3
> > 72076 Tübingen
> > 00497071/793535
> > 00491784597218
> > 
> > Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit
> allen: 
> 
> > http://www.gmx.net/de/go/multimessenger01
> > *
> > *   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/

-- 
Martin Weiss
Hackersteigle 3
72076 Tübingen
00497071/793535
00491784597218

Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal geschützt?
Jetzt absichern: https://homebanking.gmx.net/?mc=mail@footer.hb
*
*   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   |   What's new   |   Site index