Looping an equitation with different variables

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Looping an equitation with different variables

Postby miorinnovo » Wed May 29, 2019 10:25 am

I'd like to create a number of series from the same equation with a number of different independent variables. For example y=0.5*x, but where I change what x is a number of times. I'm not quite getting the loop right. I tried:l

Code: Select all

for %var {%var_list}
%v1="firstvariable"
%v2="secondvariable"

series {%var}forecast = 0.5*{%var}
next


But I get a syntax error...

Any ideas?

Thanks

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

Re: Looping an equitation with different variables

Postby EViews Gareth » Wed May 29, 2019 10:31 am

Nothing wrong with the code you posted (other than the %v1 and %v2 doing nothing).

Code: Select all

create u 100
series x=nrnd
series y=nrnd
series z=nrnd
series w=nrnd

%var_list = "x y z w"

for %var {%var_list}
%v1="firstvariable"
%v2="secondvariable"

series {%var}forecast = 0.5*{%var}
next
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Re: Looping an equitation with different variables

Postby miorinnovo » Wed May 29, 2019 10:43 am

Thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 60 guests