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

st: AW: AW: Exporting ivreg2 results in a simple long table


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: AW: Exporting ivreg2 results in a simple long table
Date   Thu, 20 May 2010 16:27:49 +0200

<> 

If you prefer the -value label-s in the output (instead of just 0 and 1),
substitute this for the -postfile- call:


*************
postfile `hdle' str15 coef estim /* 
*/ se str15 foreign using info

qui levelsof foreign

qui foreach lev in `r(levels)'{
		ivreg2 price mpg (headroom = trunk) if foreign==`lev',
ffirst
		post `hdle' ("mpg") (_b[mpg])  /* 
		*/ (_se[mpg]) ("`:lab(foreign) `lev''")
		post `hdle' ("headroom") (_b[headroom])  /* 
		*/ (_se[headroom]) ("`:lab(foreign) `lev''")
}

postclose `hdle'
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Weiss
Gesendet: Donnerstag, 20. Mai 2010 16:13
An: statalist@hsphsun2.harvard.edu
Betreff: st: AW: Exporting ivreg2 results in a simple long table


<> 

You could also try a -postfile- approach, as in Michael`s
http://www.michaelnormanmitchell.com/stow/posting-results-regression.html.
It makes the customization step considerably more straightforward in my
opinion.


*************
sysuse auto, clear

tempname hdle
capt erase info.dta

postfile `hdle' str15 coef estim /* 
*/ se foreign using info

qui levelsof foreign

qui foreach lev in `r(levels)'{
		ivreg2 price mpg (headroom = trunk) if foreign==`lev',
ffirst
		post `hdle' ("mpg") (_b[mpg]) (_se[mpg]) (`lev')
		post `hdle' ("headroom") (_b[headroom]) (_se[headroom])
(`lev')
}

postclose `hdle'

u info, clear
format estim se %9.2fc
l, noobs sepby(foreign)

//save as .dta
save mydtaresults, replace

//save as .txt
outsheet using "C:\Users\martin\Documents\Stata\mytxtresults.txt", replace
!start mytxtresults.txt

*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Chuck Cleland
Gesendet: Donnerstag, 20. Mai 2010 15:33
An: statalist@hsphsun2.harvard.edu
Betreff: st: Exporting ivreg2 results in a simple long table

Dear All,

  I am using ivreg2 in combination with a "by" prefix command as follows:

by imp: ivreg2 mydv mycov (endotx = myinstru) , ffirst

  This works fine, but I would like to save the resulting coefficients
and standard errors in a simple, long table.  Something like the following:

coef   estim    se imp
----------------------
mycov   1.11  0.40   1
endotx  3.11  0.49   1
mycov   1.07  0.51   2
endotx  3.02  0.63   2
mycov   1.61  0.38   3
endotx  3.18  0.56   3
..
endotx  2.83  0.44  10

  Then I would like to export the table to a *.dta or plain text file.
What is the best way to go about this?

Thanks,

Chuck Cleland

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index