Page 1 of 1
for loop control
Posted: Thu Mar 12, 2015 7:15 pm
by malyang713
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.
Re: for loop control
Posted: Thu Mar 12, 2015 8:18 pm
by EViews Gareth
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
Re: for loop control
Posted: Thu Mar 12, 2015 9:54 pm
by malyang713
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?
Re: for loop control
Posted: Thu Mar 12, 2015 10:01 pm
by malyang713
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.""
Re: for loop control
Posted: Thu Mar 12, 2015 10:04 pm
by malyang713
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".
Re: for loop control
Posted: Thu Mar 12, 2015 10:08 pm
by malyang713
After erasing ""s, the code works.
Thank you for your kind reply.