Page 1 of 1

string LIST looping?

Posted: Thu Jun 30, 2011 12:34 am
by dagfinnrime
Hi,

looping over sets of strings is very convenient, like the pairs in

Code: Select all

for %c %n US USA No Norway SE Sweden .... next
Looping through string LISTs is also very convenient, like in

Code: Select all

%cL = "US No Se" for %c {{%cL}} ... next
which is equivalent to

Code: Select all

for %c US No Se ... next
However. What I can't do (to the best of my knowledge), which would be very useful, is to loop over sets of string LISTs. Effectively merging the lists.

To be more precise, I would like to see a way to make

Code: Select all

%cL = "US No Se" %nL = "USA Norway Sweden" for %c {{%cL}} {{%nL}} ... next
equivalent to the code-example at top.

Is this doable?

Thanks in advance,
Dagfinn

Re: string LIST looping?

Posted: Thu Jun 30, 2011 7:59 am
by EViews Gareth
Use @winterleave to create a new string variable out of the two other ones, then loop through that one.

Re: string LIST looping?

Posted: Mon Apr 18, 2016 2:20 am
by palli_12
Hi,
this might be somewhat off topic, but here's my problem:
I attempt to loop over a list and numbers at the same time to store matrices identified by the list in a predefined matrix.
So far I tried

Code: Select all

%LIST = " Austria Belgium Cyprus Denmark Finland France Germany Greece Iceland Ireland Italy Luxembourg Malta Netherlands Norway Portugal Spain Sweden Switzerland Turkey United_Kingdom Canada United_States Japan South_Korea " 'store test results in matrix FOR %IDC {%LIST} matrix(125,2) M_BP for !i=1 to 120 step 5 matplace(M_BP, m_{%IDC}, {!i}, 1) next NEXT
, where m_{%IDC} are the 5,2-matrices, which I want to store in the 125,2 matrix (beginning with the results for austria in row one, then belgium in row 6 and so forth). Obviously I can't loop around the list as it isn't assigned to the numbers at all (in the end it will store the values for south_korea in columns 1, 6 ...). Is there any way I can solve this problem in this context?

I am using Eviews 8

Thank you very much!

Palli

Re: string LIST looping?

Posted: Mon Apr 18, 2016 4:26 am
by EViews Gareth
Hard to tell if this will work or not without seeing the workfile, but give this a try:

Code: Select all

%LIST = " Austria Belgium Cyprus Denmark Finland France Germany Greece Iceland Ireland Italy Luxembourg Malta Netherlands Norway Portugal Spain Sweden Switzerland Turkey United_Kingdom Canada United_States Japan South_Korea " 'store test results in matrix !i = 1 FOR %IDC {%LIST} matrix(125,2) M_BP matplace(M_BP, m_{%IDC}, {!i}, 1) !i=!i+5 NEXT

Re: string LIST looping?

Posted: Mon Apr 18, 2016 4:45 am
by palli_12
It worked! :D :D

Thank you so much, Gareth!