Reference string variables dynamically

For questions regarding programming in the EViews programming language.

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

schtono
Posts: 3
Joined: Tue Dec 15, 2009 8:32 am

Reference string variables dynamically

Postby schtono » Tue Dec 15, 2009 12:13 pm

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

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

Re: Reference string variables dynamically

Postby EViews Gareth » Tue Dec 15, 2009 12:21 pm

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests