Page 1 of 1

Reference string variables dynamically

Posted: Tue Dec 15, 2009 12:13 pm
by schtono
Dear EViews community,

sorry for keeping you busy today:

I have a few string variables that i want to assign some values to. The variables are called

Code: Select all

%myvar_1 %myvar_2 %myvar_3 ...
More specifically, I want to assign the values in a for loop, ie

Code: Select all

for !i=1 to 3 %ref = "myvar_" + @str(!i) {%ref} = "test" next
I get the error message: {%ref} is not defined or is an illegal command in {%ref} = "test"

Question: Is it possible to reference variable names dynamically in EViews 6 or do I have to use a workaround?

Thanks and all the best
Philipp

Re: Reference string variables dynamically

Posted: Tue Dec 15, 2009 12:21 pm
by EViews Gareth
Not possible in EViews 6.

In EViews 7 you can do it with a simple:

Code: Select all

for !i=1 to 3 %ref = "%myvar_" + @str(!i) {%ref} = "test" next