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 on April 23, and its replacement, is already up and running.

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

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

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Exporting ivreg2 results in a simple long table
Date   Thu, 20 May 2010 16:13:15 +0200


You could also try a -postfile- approach, as in Michael`s
It makes the customization step considerably more straightforward in my

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',
		post `hdle' ("mpg") (_b[mpg]) (_se[mpg]) (`lev')
		post `hdle' ("headroom") (_b[headroom]) (_se[headroom])

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



-----Ursprüngliche Nachricht-----
[] Im Auftrag von Chuck Cleland
Gesendet: Donnerstag, 20. Mai 2010 15:33
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?


Chuck Cleland

Chuck Cleland, Ph.D.
NDRI, Inc. (
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:

*   For searches and help try:

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