"Next found outside of loop" Error

For questions regarding programming in the EViews programming language.

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

luca1s
Posts: 4
Joined: Sun Dec 04, 2016 3:23 pm

"Next found outside of loop" Error

Postby luca1s » Sun Dec 04, 2016 3:51 pm

Hi all

I'm trying to run a loop of very simple AR(4) regressions for a group (named "pct"), for which I want to save the impulse responses of each series on itself. The responses are to be stored in a matrix titled "ar4". I have written the code below, but whenever I run it there is a "Next found outside of loop" error. Without the next argument it works, but obviously stops at the first variable in the group pct. Any thoughts on what is causing this issue? Thanks in advance

group pct
%v = @wlookup("pct*", "series")
pct.add {%v}

matrix (12,100) ar4

for !i to pct.@count
%name = pct.@seriesname (!i)
var test.ls 1 4 {%name}
test.impulse(12, m ,imp=gen,matbyr=temp) {%name} @ {%name}
colplace(ar4, temp, !i)
d temp
next

stop

dakila
Posts: 489
Joined: Tue Nov 24, 2015 4:57 pm

Re: "Next found outside of loop" Error

Postby dakila » Sun Dec 04, 2016 4:18 pm

change

Code: Select all

for !i to pct.@count
to

Code: Select all

for !i=1 to pct.@count

luca1s
Posts: 4
Joined: Sun Dec 04, 2016 3:23 pm

Re: "Next found outside of loop" Error

Postby luca1s » Sun Dec 04, 2016 4:34 pm

Thanks for the quick reply, apologies but this was a typo in the request on the forum (instead of copy paste-ing, I retyped it a bit too hastily).

The program actually was written containing your suggestion.
Nonetheless the Error occurred.

group pct
%v = @wlookup("pct*", "series")
pct.add {%v}

matrix (12,100) ar4

for !i=1 to pct.@count
%name = pct.@seriesname (!i)
var test.ls 1 4 {%name}
test.impulse(12, m ,imp=gen,matbyr=temp) {%name} @ {%name}
colplace(ar4, temp, !i)
d temp
next

stop

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

Re: "Next found outside of loop" Error

Postby EViews Gareth » Sun Dec 04, 2016 5:21 pm

Code: Select all

create u 100 for !i=1 to 10 series pct!i=nrnd next group pct %v = @wlookup("pct*", "series") pct.add {%v} matrix (12,100) ar4 for !i=1 to pct.@count %name = pct.@seriesname (!i) var test.ls 1 4 {%name} test.impulse(12, m ,imp=gen,matbyr=temp) {%name} @ {%name} colplace(ar4, temp, !i) d temp next
Works fine.

luca1s
Posts: 4
Joined: Sun Dec 04, 2016 3:23 pm

Re: "Next found outside of loop" Error

Postby luca1s » Sun Dec 04, 2016 5:30 pm

Following you reply, I created a new program file to re-test the code using my own data, and weirdly enough now it did work. I'm not sure what corrupted the other file, but I won't lose any more time on it. Given that I already lost some time on something that could be solved so simply, I am equally thankful to you, as embarrassed to have come to the forum with this.

My apologies, and again many thanks for the responses.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest