Page 1 of 1
Can you put a Next inside a If condition?
Posted: Wed Jul 30, 2014 8:39 am
by abossie
I am getting a "next found outside of loop or IF statement" error. Not sure if I am just missing something or if I cant do this. i want to do something like this:
Code: Select all
for %v x y z
scalar old_error=@errorcount
var var_base.ls 1 4 gdp {%v}
scalar new_error=@errorcount
if new_error>old_error then
next
endif
var_base.svar(amatrix=something, bmatrix=something_else}
next
My code is more complicated, as I have several for loops that need to be "NEXTed" if the var produces a near singular matrix.
Re: Can you put a Next inside a If condition?
Posted: Wed Jul 30, 2014 8:47 am
by EViews Gareth
Unfortunately not, no.
You can't have the next statement be conditional.
Re: Can you put a Next inside a If condition?
Posted: Wed Jul 30, 2014 8:51 am
by startz
Try something like
if not(new_error>old_error) then
var_base.svar(amatrix=something, bmatrix=something_else}
endif
next
Re: Can you put a Next inside a If condition?
Posted: Mon Aug 04, 2014 8:40 pm
by abossie
This does not seem to work.
Try something like
if not(new_error>old_error) then
var_base.svar(amatrix=something, bmatrix=something_else}
endif
next
Re: Can you put a Next inside a If condition?
Posted: Tue Aug 05, 2014 6:33 am
by startz
What happens?
Re: Can you put a Next inside a If condition?
Posted: Tue Aug 05, 2014 7:19 am
by abossie
I get the same error message as above.
Re: Can you put a Next inside a If condition?
Posted: Tue Aug 05, 2014 7:29 am
by startz
Hmmm, could you post your new code.
Re: Can you put a Next inside a If condition?
Posted: Tue Aug 05, 2014 8:25 am
by abossie
I take it back. It works in the simple version above, so I assume the problem with my program is elsewhere. Anyway I realized I need a marker for when I cannot run a VAR so I have solved this problem by making it an if/else condition.
Thanks for the help.