Page 1 of 1

Replacement variable to replace various strings in loop

Posted: Fri Jul 09, 2010 3:37 pm
by raphbrun
I have a program where the same loop is coming at various occasions:

for %y fr us uk

If I then need to change my loop, e.g. replace "for %y fr us uk" by "for %y fr us", I will have to do so every time the loop is coming in the program. Ideally, I would like to make only one change and see this change reflected in all the loops. I am thinking of replacing the content of the loop by a replacement variable to be defined at the start of the program but the way I do it does not work:

%loop = "%y " + "fr " + "us " + "uk"
for %loop
scalar s_{%y}=1
next

The following does not work neither:

%loop = "%y " + "fr " + "us " + "uk"
for {%loop}
scalar s_{%y}=1
next

I guess this is an important question while programing. Any idea?

Re: Replacement variable to replace various strings in loop

Posted: Fri Jul 09, 2010 4:16 pm
by EViews Gareth

Code: Select all

%loop = "fr " + "us " + "uk" for %y {%loop} scalar s_{%y}=1 next

Re: Replacement variable to replace various strings in loop

Posted: Mon Jul 12, 2010 10:57 am
by raphbrun
Thanks

Your reply makes sense and must be correct but I guess it is only be valid on later versions of Eviews. I have tried it on Eviews 5 and it does not work.I am aware Eviews 7 has made progress with strings and I suppose your code must be working on the latest version.

Thanks again

Re: Replacement variable to replace various strings in loop

Posted: Mon Jul 12, 2010 11:23 am
by EViews Glenn
The replacement of the loop strings is a version 7 feature.