Page 1 of 1

Report and Excel

Posted: Wed Aug 21, 2013 8:14 am
by schokakola
Hi altogether,

I've got a problem with the report command when I try to save my table to an excel spreedsheet.
Here is my code:

Code: Select all

report(action=define,hlabels=||"","Country","1stepAR","2stepAR","3stepAR","4stepAR","Country","1stepFP","2stepFP","3stepFP","4stepFP",$
		"Country","1stepEC","2stepEC","3stepEC","4stepEC","Country","1stepNO","2stepNO","3stepNO","4stepNO",$
		"Country","1stepALL","2stepALL","3stepALL","4stepALL"||)
report(row=new,col=new) MAEAR MAEFP MAEEC MAENO MAEALL
open copy AbsoluteMeanError.xls
report(action=show,format=xls,unit=copy)

Where MAEAR etc. are matrices with 5 columns and 47 rows each. I left the first column blank since RATS doesn't write any data into it in this case.
The Excel spreedsheet is generated, but the system crashes down when writing the data into it. I always have to stop the process. When I simply use the window option everything is fine.

Thanks for helpful ideas and hints.

Best regards,
Julia

Re: Report and Excel

Posted: Fri Aug 23, 2013 12:24 pm
by TomDoan
That seems to work fine when I do it with randomly generated data. You'll probably have to post your full program + data so we can see what it's doing.

Re: Report and Excel

Posted: Fri Aug 30, 2013 4:18 am
by schokakola
Well, the code is quite long. Sorry for that. I first estimate several models and save the corresponding forecasting erros. The ext step is then the part where I generate and save the mean absolute errors for each model for several time periods.
Thank You!

Code: Select all


* AR - VERGLEICHSMODELL *
dofor i = laenderFP
	comp preg=1, steps=4, kontemp=1, fsteps=4
	declare rectangular[series] forcerrorAR(47,steps) absforcerrorAR(47,steps) forcAR(47,steps)
	clear forcerror absforcerror forconestep1 forconestepar
	do ftime = 2003:1,2012:4

	estimate(model=mar(i),noprint)  1985:1 ftime-1

	forecast(model=mar(i),print=preg,result=forc1) * fsteps ftime

	* PROGNOSEFEHLER AR-MODELL
	do fsteps=1,steps
		set forcAR(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 =  forc1(1)(t)
		set forcerrorAR(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = ( dexport(i)(t) - forc1(1)(t) )**2
		set absforcerrorAR(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = abs( dexport(i)(t) - forc1(1)(t) )
	end do fsteps
	end do ftime
end dofor i
disp i

* FUTURE PRODUCTION INDEX
dofor i = laenderFP
	comp preg=1, steps=4, kontemp=1, fsteps=4
	declare rectangular[series] forcerrorFP(47,steps) absforcerrorFP(47,steps) forcFP(47,steps)
	clear forcerror absforcerror forconestep1 forconestepar
	do ftime = 2003:1,2012:4

        	estimate(model=mexpfp(i))   1985:1 ftime-1

        	forecast(model=mexpfp(i),print,result=forc2) * fsteps ftime
		if kontemp==1 {
			forecast(input,model=mexpfp(i),print,result=forc2) * fsteps ftime
			# 0 fp(i)(ftime)-forc2(2)(ftime)
		}
	do fsteps=1,steps
		set forcFP(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 =  forc2(1)(t)
		set forcerrorFP(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = ( dexport(i)(t) - forc2(1)(t) )**2
		set absforcerrorFP(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = abs( dexport(i)(t) - forc2(1)(t) )
	end do fsteps
	end do ftime
end dofor i
disp i

* EUC EXPORT EXPECTATIONS
dofor i = laenderEC
	comp preg=1, steps=4, kontemp=1, fsteps=4
	declare rectangular[series] forcerrorEC(47,steps) absforcerrorEC(47,steps) forcEC(47,steps)
	clear forcerror absforcerror forconestep1 forconestepar
	do ftime = 2003:1,2012:4

        	estimate(model=mexpec(i))   1985:1 ftime-1

        	forecast(model=mexpec(i),print,result=forc3) * fsteps ftime
		if kontemp==1 {
			forecast(input,model=mexpec(i),print,result=forc3) * fsteps ftime
			# 0 expec(i)(ftime)-forc3(2)(ftime)
		}
	do fsteps=1,steps
		set forcEC(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 =  forc3(1)(t)
		set forcerrorEC(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = ( dexport(i)(t) - forc3(1)(t) )**2
		set absforcerrorEC(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = abs( dexport(i)(t) - forc3(1)(t) )
	end do fsteps
	end do ftime
end dofor i
disp i

* FP-INDEX & EUC EXPORT EXPECTATIONS
dofor i = laenderEC
	comp preg=1, steps=4, kontemp=1, fsteps=4
	declare rectangular[series] forcerrorALL(47,steps) absforcerrorALL(47,steps) forcALL(47,steps)
	clear forcerror absforcerror forconestep1 forconestepar
	do ftime = 2003:1,2012:4

        	estimate(model=mexpall(i))   1985:1 ftime-1

        	forecast(model=mexpall(i),print,result=forc4) * fsteps ftime
		if kontemp==1 {
			forecast(input,model=mexpall(i),print,result=forc4) * fsteps ftime
			# 0 fp(i)(ftime)-forc2(2)(ftime) 0 expec(i)(ftime)-forc3(2)(ftime)
		}
	do fsteps=1,steps
		set forcALL(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 =  forc4(1)(t)
		set forcerrorALL(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = ( dexport(i)(t) - forc4(1)(t) )**2
		set absforcerrorALL(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = abs( dexport(i)(t) - forc4(1)(t) )
	end do fsteps
	end do ftime
end dofor i
disp i

* NEW ORDERS (USA)
dofor i = laenderNO
	comp preg=1, steps=4, kontemp=1, fsteps=4
	declare rectangular[series] forcerrorNO(47,steps) absforcerrorNO(47,steps) forcNO(47,steps)
	clear forcerror absforcerror forconestep1 forconestepar
	do ftime = 2003:1,2012:4

        	estimate(model=mexpno(i))   1985:1 ftime-1

        	forecast(model=mexpno(i),print,result=forc5) * fsteps ftime
		if kontemp==1 {
			forecast(input,model=mexpno(i),print,result=forc5) * fsteps ftime
			# 0 neworder(i)(ftime)-forc5(2)(ftime)
		}
	do fsteps=1,steps
		set forcNO(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 =  forc5(1)(t)
		set forcerrorNO(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = ( dexport(i)(t) - forc5(1)(t) )**2
		set absforcerrorNO(i,fsteps) ftime+fsteps-1 ftime+fsteps-1 = abs( dexport(i)(t) - forc5(1)(t) )
	end do fsteps
	end do ftime
end dofor i
disp i


*** SAVE MEAN ABSOLUTE ERRORS ***
*** AR-MODEL ***
dec rec[real] MAEAR(47,steps+1)  MAE03AR(47,steps+1) MAE08AR(47,steps+1)
dofor i = laenderFP
	comp MAEAR(i,1) = i, MAE03AR(i,1) = i, MAE08AR(i,1) = i
	do fsteps = 1,fsteps
   	      statistics(noprint) absforcerrorAR(i,fsteps) 2003:1 2007:4       ; comp MAE03AR(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorAR(i,fsteps) 2008:1 2012:4       ; comp MAE08AR(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorAR(i,fsteps) 2003:1 2012:4       ; comp MAEAR(i,fsteps+1)=%mean
	end do fsteps
end dofor i

*** FP-INDEX ***
dec rec[real] MAEFP(47,steps+1)  MAE03FP(47,steps+1) MAE08FP(47,steps+1)
dofor i = laenderFP
	comp MAEFP(i,1) = i, MAE03FP(i,1) = i, MAE08FP(i,1) = i
	do fsteps = 1,fsteps
   	      statistics(noprint) absforcerrorFP(i,fsteps) 2003:1 2007:4       ; comp MAE03FP(i,fsteps+1)=%mean
   	      statistics(noprint) absforcerrorFP(i,fsteps) 2008:1 2012:4       ; comp MAE08FP(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorFP(i,fsteps) 2003:1 2012:4       ; comp MAEFP(i,fsteps+1)=%mean
	end do fsteps
end dofor i

*** EUC EXPORT EXPECTAIONS ***
dec rec[real] MAEEC(47,steps+1)  MAE03EC(47,steps+1) MAE08EC(47,steps+1)
dofor i = laenderEC
	comp MAEEC(i,1) = i, MAE03EC(i,1) = i, MAE08EC(i,1) = i
	do fsteps = 1,fsteps
   	      statistics(noprint) absforcerrorEC(i,fsteps) 2003:1 2007:4       ; comp MAE03EC(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorEC(i,fsteps) 2008:1 2012:4       ; comp MAE08EC(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorEC(i,fsteps) 2003:1 2012:4       ; comp MAEEC(i,fsteps+1)=%mean
	end do fsteps
end dofor i

*** FP-INDEX & EXPORT EXPECTATIONS ***
dec rec[real] MAEALL(47,steps+1)  MAE03ALL(47,steps+1) MAE08ALL(47,steps+1)
dofor i = laenderEC
	comp MAEALL(i,1) = i, MAE03ALL(i,1) = i, MAE08ALL(i,1) = i
	do fsteps = 1,fsteps
  	      statistics(noprint) absforcerrorALL(i,fsteps) 2003:1 2007:4       ; comp MAE03ALL(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorALL(i,fsteps) 2008:1 2012:4       ; comp MAE08ALL(i,fsteps+1)=%mean
    	      statistics(noprint) absforcerrorALL(i,fsteps) 2003:1 2012:4       ; comp MAEALL(i,fsteps+1)=%mean
	end do fsteps
end dofor i

*** NEW ORDERS ***
dec rec[real] MAENO(47,steps+1)  MAE03NO(47,steps+1) MAE08NO(47,steps+1)
dofor i = laenderNO
	comp MAENO(i,1) = i, MAE03NO(i,1) = i, MAE08NO(i,1) = i
	do fsteps = 1,fsteps
   	      statistics(noprint) absforcerrorNO(i,fsteps) 2003:1 2007:4       ; comp MAE03NO(i,fsteps+1)=%mean
   	      statistics(noprint) absforcerrorNO(i,fsteps) 2008:1 2012:4       ; comp MAE08NO(i,fsteps+1)=%mean
   	      statistics(noprint) absforcerrorNO(i,fsteps) 2003:1 2012:4       ; comp MAENO(i,fsteps+1)=%mean
	end do fsteps
end dofor i

Re: Report and Excel

Posted: Fri Jul 18, 2014 2:50 pm
by Todd_M
Hi,

I'm actually having this same issue. When I try to write the report to excel my RATS freezes up and I need to end the process. I can display the report just fine in the RATS output window. Did you figure out what is wrong?

-Todd

Re: Report and Excel

Posted: Fri Jul 18, 2014 4:14 pm
by TomDoan
What version of RATS?