Page 1 of 1

Nesting loops

Posted: Wed Oct 15, 2014 2:00 pm
by ecardamone
Hi,

I think I am trying to nest loops, but not successfully :(

This is a simplified version of what I have:
%x = "rd"
%z = "go"

for %j tot p
q_us{%z}{%j}_{%x}.label(S) BEA
for %k gdp private
q_US{%z}{%j}_{%x}.displayname US, GO $2009, {%k}
next
next

Ultimately, I want the label 'source' (S) for 'tot' and 'p' to be the same, but the display name should differ - 'tot' should correspond to 'gdp' and 'p' to 'private'. However, when I run this, 'private' shows up as the display name for both.

Can someone help, please? Thanks!!

Re: Nesting loops

Posted: Wed Oct 15, 2014 2:29 pm
by EViews Gareth
You can't do what you want with two loops.

I think I would do it this way:

Code: Select all

%x = "rd" %z = "go" %js = "tot p" %dnames = "gdp private" for !j = 1 to @wcount(%js) %j = @word(%js,!j) %k = @word(%dnames, !j) q_us{%z}{%j}_{%x}.label(S) BEA q_US{%z}{%j}_{%x}.displayname US, GO $2009, {%k} next

Re: Nesting loops

Posted: Thu Oct 16, 2014 6:07 am
by ecardamone
Thank you, Gareth! You are a genius!