Page 1 of 1

"Next found outside of loop" Error

Posted: Sun Dec 04, 2016 3:51 pm
by luca1s
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

Re: "Next found outside of loop" Error

Posted: Sun Dec 04, 2016 4:18 pm
by dakila
change

Code: Select all

for !i to pct.@count
to

Code: Select all

for !i=1 to pct.@count

Re: "Next found outside of loop" Error

Posted: Sun Dec 04, 2016 4:34 pm
by luca1s
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

Re: "Next found outside of loop" Error

Posted: Sun Dec 04, 2016 5:21 pm
by EViews Gareth

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.

Re: "Next found outside of loop" Error

Posted: Sun Dec 04, 2016 5:30 pm
by luca1s
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.