Can you put a Next inside a If condition?

For questions regarding programming in the EViews programming language.

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

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Can you put a Next inside a If condition?

Postby abossie » Wed Jul 30, 2014 8:39 am

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.

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

Re: Can you put a Next inside a If condition?

Postby EViews Gareth » Wed Jul 30, 2014 8:47 am

Unfortunately not, no.

You can't have the next statement be conditional.

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Can you put a Next inside a If condition?

Postby startz » Wed Jul 30, 2014 8:51 am

Try something like

if not(new_error>old_error) then
var_base.svar(amatrix=something, bmatrix=something_else}
endif

next

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Re: Can you put a Next inside a If condition?

Postby abossie » Mon Aug 04, 2014 8:40 pm

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

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Can you put a Next inside a If condition?

Postby startz » Tue Aug 05, 2014 6:33 am

What happens?

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Re: Can you put a Next inside a If condition?

Postby abossie » Tue Aug 05, 2014 7:19 am

I get the same error message as above.

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Can you put a Next inside a If condition?

Postby startz » Tue Aug 05, 2014 7:29 am

Hmmm, could you post your new code.

abossie
Posts: 15
Joined: Tue Jan 31, 2012 10:54 am

Re: Can you put a Next inside a If condition?

Postby abossie » Tue Aug 05, 2014 8:25 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests