For loop over series

For questions regarding programming in the EViews programming language.

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

farrel
Posts: 111
Joined: Thu Sep 18, 2008 11:13 pm

For loop over series

Postby farrel » Mon Mar 08, 2021 7:14 am

Hi

Anyone knows how to quickly and sequentially loop over the following 130 series and put them in a group?
series01, series02, series03, ..., series10, series11, ..., series129, series130

I just struggle how to sequentially loop over the first 9 series ...


Andrejs

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

Re: For loop over series

Postby EViews Gareth » Mon Mar 08, 2021 8:19 am

Well if they're named like that, and there aren't any other series that start with "series" you could just do:

Code: Select all

group g series*
But more generally you have to condition on the number, unfortunately:

Code: Select all

group g for !i=1 to 130 if !i<10 then g.add series0{!i} else g.add series{!i} endif next
Or you could just do two for loops.

Code: Select all

for !i=1 to 9 g.add series0{!i} next for !i=10 to 130 g.add series{!i} next

farrel
Posts: 111
Joined: Thu Sep 18, 2008 11:13 pm

Re: For loop over series

Postby farrel » Mon Mar 08, 2021 11:26 am

Thanks, Gareth!
In the end, this is what I also did - split before and after 10...
I was thinking, maybe, there is more elegant way how to do it ..

Andrejs


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests