string LIST looping?

For questions regarding programming in the EViews programming language.

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

dagfinnrime
Posts: 54
Joined: Sat Oct 11, 2008 9:37 am
Location: Oslo
Contact:

string LIST looping?

Postby dagfinnrime » Thu Jun 30, 2011 12:34 am

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

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

Re: string LIST looping?

Postby EViews Gareth » Thu Jun 30, 2011 7:59 am

Use @winterleave to create a new string variable out of the two other ones, then loop through that one.

palli_12
Posts: 2
Joined: Mon Apr 18, 2016 1:55 am

Re: string LIST looping?

Postby palli_12 » Mon Apr 18, 2016 2:20 am

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

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

Re: string LIST looping?

Postby EViews Gareth » Mon Apr 18, 2016 4:26 am

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

palli_12
Posts: 2
Joined: Mon Apr 18, 2016 1:55 am

Re: string LIST looping?

Postby palli_12 » Mon Apr 18, 2016 4:45 am

It worked! :D :D

Thank you so much, Gareth!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests