Page 1 of 1

Calling a subroutine in a loop

Posted: Wed Feb 27, 2013 10:05 am
by thaigrrr
Good morning,

I'm a newbie with EViews and having some problem calling a subroutine within a loop. My code:

Code: Select all

include progguts %rec_end = "2012:2" %rec_start = %ols_stop smpl %rec_end %rec_start !n_qtr = @obssmpl for !i = 1 to (!n_qtr-1) %rec_start = @datestr(@dateval(%ols_stop)-!i+1, "yyyy:q") %ols_stop = %rec_start show %ols_stop ' smpl %ols_start %ols_stop series jan_mar = jan15s + feb15s + mar15s group depvar bgvol group seasonals jan_mar sep15s oct15s nov15s dec15s group nonpxvars constant exports(-2) px group pxvars call newregs next
The code executes fine (i.e., showing all modified %ols_stop) if the 7 lines above "next" are excluded. It only executes once if the code is as-is.

I've been searching this forum and the internet and couldn't find anything close to answer my question. I did, however, find this post that looks to have similar issue as mine, but it's received no reply.

Any help is greatly appreciated. I'm using EViews 7.

Re: Calling a subroutine in a loop

Posted: Wed Feb 27, 2013 10:33 am
by EViews Gareth
Hard to say without seeing the rest of the program/workfiles.

But if I were to guess, I'd bet that your subroutine was resetting !i.

Re: Calling a subroutine in a loop

Posted: Wed Feb 27, 2013 10:41 am
by thaigrrr
That was it!!! Oh, THANK YOU, THANK YOU, THANK YOU!!!