Looping over an alpha list?

For questions regarding programming in the EViews programming language.

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

caburdick
Posts: 24
Joined: Mon Jun 15, 2009 7:41 am

Looping over an alpha list?

Postby caburdick » Mon Jun 15, 2009 10:34 am

How can I determine the length of an alpha series so that I can loop over it's elements.

I have a list of states and would like to loop over the list:

alpha mystates
alpha(1) = "ny"
alpha(2) = "tx"

for !i = 1 to length(mystates)
%state = mystate(!i)
Do state specific stuff
next !i

How do I determine length(mystates)?

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

Re: Looping over an alpha list?

Postby EViews Gareth » Mon Jun 15, 2009 12:16 pm

Well an alpha is the length of the workfile, so you can use one of the @obs type functions to get that information.



It strikes me that you may be using an alpha series for something that a table might be more suited for. If you're looking for somewhere to store strings, a table is probably better than an alpha.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests