Output direct to Excel

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
Anja
Posts: 8
Joined: Tue Aug 12, 2008 10:44 am

Output direct to Excel

Unread post by Anja »

Hi,
Is it possible to direct output from a model directly to an Excel spread sheet?
Thank You,
Anja
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Output direct to Excel

Unread post by TomDoan »

Not directly, as the full table doesn't lend itself to a spreadsheet-style display. However, you can use REPORT ending with REPORT(action=show,format=xls) to put whatever output you want into the spreadsheet. The following is an example using one of the sample data sets.

Code: Select all

calendar 1922
allocate 1941:1
open data fooddata.dat
data(format=free,org=obs) / foodcons prretail dispinc foodprod prfarm
set trend = t
set avgprices = (prfarm+prfarm{1})/2.0
*
report(action=define)
report(atrow=1,atcol=1) "R**2"
report(atrow=2,atcol=1) "DW"
linreg foodcons
# constant prretail dispinc trend
report(regressors)
report(atrow=1,column=current) %rsquared
report(atrow=2,column=current) %durbin
linreg foodcons
# constant prretail dispinc{0 1}
report(regressors)
report(atrow=1,column=current) %rsquared
report(atrow=2,column=current) %durbin
report(action=format,picture="*.###")
*
open copy testoutput.xls
report(action=show,format=xls,unit=copy)
avik
Posts: 1
Joined: Fri Jul 15, 2011 4:27 pm

Re: Output direct to Excel

Unread post by avik »

Hi Tom,
I followed your example above and was able to create an Excel file with the output of several regressions.
My question is as follows:
Currently the output comes as

Reg1 Reg2 Reg3 Reg4 Reg5

R**2 0.87 0.02 0.03 0.02 0.06

Constant 0.17 -0.02 0.02 -0.03 0.02
t-stat 3.76 -0.16 0.12 -0.28 0.19

EV1 0.53 0.02 -0.06 -0.04 0.09
19.20 0.36 -1.31 -1.11 1.88

EV2 -0.13 -0.09 0.14 0.06 0.04
-6.32 -1.58 2.41 1.33 0.55

EV3 0.10 0.08 -0.06 0.11 -0.19
4.54 1.56 -0.99 2.48 -3.90

Is there a way to get the output in a "transposed" format (so that the explanatory variables are in columns and the regressions are in rows)?
I played with the REPORT procedure, but could not get it to transpose the output.

Thanks.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Output direct to Excel

Unread post by TomDoan »

avik wrote:Hi Tom,
I followed your example above and was able to create an Excel file with the output of several regressions.
My question is as follows:
Currently the output comes as

Reg1 Reg2 Reg3 Reg4 Reg5

R**2 0.87 0.02 0.03 0.02 0.06

Constant 0.17 -0.02 0.02 -0.03 0.02
t-stat 3.76 -0.16 0.12 -0.28 0.19

EV1 0.53 0.02 -0.06 -0.04 0.09
19.20 0.36 -1.31 -1.11 1.88

EV2 -0.13 -0.09 0.14 0.06 0.04
-6.32 -1.58 2.41 1.33 0.55

EV3 0.10 0.08 -0.06 0.11 -0.19
4.54 1.56 -0.99 2.48 -3.90

Is there a way to get the output in a "transposed" format (so that the explanatory variables are in columns and the regressions are in rows)?
I played with the REPORT procedure, but could not get it to transpose the output.

Thanks.
No. The REGRESSORS option just works with each regression being in a separate column. While I've seen summary tables for regressions running the other direction, they almost always have had the same set of regressors in each equation, which is much easier to handle. The key feature of REGRESSORS is that it lets you vary the set of explanatory variables and they all get slotted appropriately. The following would let you flip around the table so coefficients are in columns. This would be attached to the end of the KLEIN.RPF example:

Code: Select all

report(action=define)
linreg  privwage
# constant  prod{0 1}  trend
report(atrow=1,atcol=2,fillby=rows) %eqnreglabels(0)
report(atrow=2,atcol=1,fillby=rows) "OLS" %beta
linreg(inst)  privwage
# constant  prod{0 1}  trend
report(atrow=3,atcol=1,fillby=rows) "2SLS" %beta
@liml privwage
# constant  prod{0 1}  trend
report(atrow=4,atcol=1,fillby=rows) "LIML" %beta
report(action=format,atcol=2,width=8) 
report(action=show)
Post Reply