Looping Through Replacement Variables

For questions regarding programming in the EViews programming language.

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

alicia
Posts: 2
Joined: Thu Oct 29, 2015 5:38 am

Looping Through Replacement Variables

Postby alicia » Thu Oct 29, 2015 5:51 am

I'm trying to create a program that contains many equation specifications, and then loops through them one at a time and performs various actions on them. I'm having trouble with the replacement variables.

When I run the code below I get an error: MYEQUATION1 is not defined in "LS MYEQUATION1"

Code: Select all

%myEquation1 = "depvar c indepvar1" %myEquation2 = "depvar c indepvar1 indepvar2" for !mycounter=1 to 2 %Equation="myEquation"+@str(!mycounter) ls {%Equation} next
I'm sure it's something simple, but I'm just not seeing it!

Thanks.

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

Re: Looping Through Replacement Variables

Postby EViews Gareth » Thu Oct 29, 2015 6:40 am

Try:

Code: Select all

for !mycounter=1 to 2 %Equation="%myEquation"+@str(!mycounter) ls {{%equation}} next

alicia
Posts: 2
Joined: Thu Oct 29, 2015 5:38 am

Re: Looping Through Replacement Variables

Postby alicia » Thu Oct 29, 2015 4:37 pm

Perfect!

Thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests