for loop control

For questions regarding programming in the EViews programming language.

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

malyang713
Posts: 7
Joined: Thu Mar 06, 2014 5:14 pm

for loop control

Postby malyang713 » Thu Mar 12, 2015 7:15 pm

Hello, I have a simple question
Is there any way to loop by irregular numbers?
for example: (It has a syntax error)

for !i= 1, 3, 7, 11, 13, 15, 20, 21, 29

series x{!i}=@nrnd
series y{!i}=0.9*x{!i}

next



How do I loop the program using control variable i, using irregular numbers?
Thank you for your attention.

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

Re: for loop control

Postby EViews Gareth » Thu Mar 12, 2015 8:18 pm

Code: Select all

for %i "1 3 7 11 13 15 20 21 29" series x{%i}=@nrnd series y{%i}=0.9*x{%i} next

malyang713
Posts: 7
Joined: Thu Mar 06, 2014 5:14 pm

Re: for loop control

Postby malyang713 » Thu Mar 12, 2015 9:54 pm

Thank you for your kind reply.

However, it doesn't work.
The error occurs: "Syntax error in "SERIES X{%I}=@NRND.""

How do I can fix this?

malyang713
Posts: 7
Joined: Thu Mar 06, 2014 5:14 pm

Re: for loop control

Postby malyang713 » Thu Mar 12, 2015 10:01 pm

I think it is because of the space after "%i=" in the code. But after fixing that, it still doesn't work.
Error: "Numeric operator applied to string data in "SERIES X{%I}=@NRND.""

malyang713
Posts: 7
Joined: Thu Mar 06, 2014 5:14 pm

Re: for loop control

Postby malyang713 » Thu Mar 12, 2015 10:04 pm

I used the code:

for %i "1 3 7 11 13 15 20 21 29"

series x{%i}=@nrnd
series y{%i}=0.9*x{%i}

next

But it doesn't work
Error: Syntax error in "SERIES X{%I}=@NRND".

malyang713
Posts: 7
Joined: Thu Mar 06, 2014 5:14 pm

Re: for loop control

Postby malyang713 » Thu Mar 12, 2015 10:08 pm

After erasing ""s, the code works.
Thank you for your kind reply.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests