Calling a subroutine in a loop

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

thaigrrr
Posts: 9
Joined: Wed Feb 27, 2013 9:49 am

Calling a subroutine in a loop

Postby thaigrrr » Wed Feb 27, 2013 10:05 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13611
Joined: Tue Sep 16, 2008 5:38 pm

Re: Calling a subroutine in a loop

Postby EViews Gareth » Wed Feb 27, 2013 10:33 am

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.

thaigrrr
Posts: 9
Joined: Wed Feb 27, 2013 9:49 am

Re: Calling a subroutine in a loop

Postby thaigrrr » Wed Feb 27, 2013 10:41 am

That was it!!! Oh, THANK YOU, THANK YOU, THANK YOU!!!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests