loop with string variables

For questions regarding programming in the EViews programming language.

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

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

Re: loop with string variables

Postby EViews Gareth » Wed Nov 17, 2010 11:45 am

You're doing the looping correctly. However you are not using string variables correctly. A string variable is literally that; a variable containing a piece of text. If you want to use an EViews object with a name equal to the piece of text, you have to enclose the string variable in { }.

i.e. when you say

Code: Select all

%i/100
You're saying "take the piece of text stored in %i and divide it by 100."

When you say

Code: Select all

{%i}/100
You're saying "take the object called %i and divide its contents by 100."


Thus you should change your code to be:

Code: Select all

for %i x y z j k series pc_{%i}={%}i/{%i}(-1)*100-100 next

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests