FOR Loops

For questions regarding programming in the EViews programming language.

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

John Lewis
Posts: 3
Joined: Thu May 17, 2012 3:54 am

FOR Loops

Postby John Lewis » Thu May 17, 2012 11:27 am

Hi everyone!

I have a number of string values in a series Z (say, Z(1)="firms", Z(2)="cars", Z(3)="legs", Z(4)="shops").

At the same time, I need to use the following FOR statement:

FOT %ARQ firms cars legs shops
....
NEXT

Could you please help how to use this Z series in the FOR statement instead of listing all the string values in the line?

Thank you for all kinds of help!

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

Re: FOR Loops

Postby EViews Gareth » Thu May 17, 2012 11:56 am

If they're actually in an alpha series, it is not easy to do with a string loop. You can do it with a number loop though:

Code: Select all

for !i=1 to @obsrange %arq = z(!i) next

John Lewis
Posts: 3
Joined: Thu May 17, 2012 3:54 am

Re: FOR Loops

Postby John Lewis » Thu May 17, 2012 12:41 pm

Thanks a lot!

Unfortunately I have a problem with aplling @obsrange to a alpha-series Z. EViews states: "Alpha sent to a function which operates on a matrix". Could you please help with this? How to obtain correctly the lenght of an alpha series?

Thank you very much!

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

Re: FOR Loops

Postby EViews Gareth » Thu May 17, 2012 1:49 pm

@obsrange doesn't require an argument. It doesn't need to be applied to a series. It just tells you the length of the workfile (all series are the same length as the workfile).


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests