Bookmark and Share

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]

st: inverting a stored table of regression results - then exporting to a cvs/excel file


From   "Benhoen2" <[email protected]>
To   <[email protected]>
Subject   st: inverting a stored table of regression results - then exporting to a cvs/excel file
Date   Wed, 3 Nov 2010 15:05:08 -0400

Hello statalisters,

I have a .do file that produces a stored set of results:

sysuse auto, replace
g rcat = int((100)*runiform())
egen catg = cut(rcat),group(4)
tab1 catg

eststo clear
qui levelsof catg, local(levels)
qui foreach i of local levels {
	regress price mpg weight foreign
	eststo model`i'
	}
*
estout,cells(b(star fmt(3))) stats (r2_a N depvar, fmt(%5.2f %9.0g))
collabels(none)

This produces this output:


----------------------------------------------------------------------------
                   model0          model1          model2          model3   
----------------------------------------------------------------------------
mpg                21.854          21.854          21.854          21.854   
weight              3.465***        3.465***        3.465***        3.465***
foreign          3673.060***     3673.060***     3673.060***     3673.060***
_cons           -5853.696       -5853.696       -5853.696       -5853.696   
----------------------------------------------------------------------------
r2_a                 0.48            0.48            0.48            0.48   
N                      74              74              74              74   
depvar              price           price           price           price   
----------------------------------------------------------------------------

I will run a similar .do file with a relatively small number of regressors
yet over a relatively large number of groups (n=400).  Ideally I would like
to be able to invert the output so that the regressors are across the top
and the model numbers are rows. Is that possible?  I played around with
"estout matrix(matname)" but was unclear how to apply this.  Any help here
would be great.

Secondly I want to export this output to a csv or excel file for further
work.  Again, ideally I could preserve the format, for instance the stars.
Any ideas?  I was able to clumsily do this by copying and special pasting
"transpose", removing rows etc. into excel, but it would be great if I could
automate at least parts of it. 

Thanks, as always,

Ben
Ben Hoen
LBNL
Office: 845-758-1896
Cell: 718-812-7589
[email protected]



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index