Page 1 of 1

For loop over series

Posted: Mon Mar 08, 2021 7:14 am
by farrel
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

Re: For loop over series

Posted: Mon Mar 08, 2021 8:19 am
by EViews Gareth
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

Re: For loop over series

Posted: Mon Mar 08, 2021 11:26 am
by farrel
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