Page 1 of 1

Aggregating Cross-Sections in Pools

Posted: Mon Aug 09, 2010 2:06 pm
by pmgm
Dear all,

I would like to aggregate cross-sections (e.g. countries into regions) in a pooled workfile. So far I have got (e.g. for Asia):

for %v GDP POP INF NER EXP IMP FDI
series {%v}_Asia = 0
for %c BN FJ ID KH KP LA MM MN MY PG
{%v}_Asia = {%v}_Asia + {%v}_{%c}
next
next

Not the tidiest of codes, as I need to repeat this for all regions (about 20). Could anyone suggest a way to include the regions in the loop?

Many thanks.

Re: Aggregating Cross-Sections in Pools

Posted: Mon Aug 09, 2010 2:20 pm
by EViews Gareth
Like this ?:

Code: Select all

for %r asia europe americas for %v GDP POP INF NER EXP IMP FDI series {%v}_{%r} = 0 for %c BN FJ ID KH KP LA MM MN MY PG {%v}_{%r} = {%v}_{%r} + {%v}_{%c} next next next

Re: Aggregating Cross-Sections in Pools

Posted: Tue Aug 10, 2010 1:25 am
by pmgm
Thank you for your quick reply, Gareth. Unfortunately that would not work, since each region has different members. Say we have:

Asia = BN FJ ID KH KP LA MM MN MY PG
Americas = CR CU DO GT JM MX NI SR TT
Africa = AO BF CV TD KM ET GA GN GW KE
Europe = FR DE LU NL GR IS IT
etc…

The code suggested would create regional variables with the same values (_Asia = _Europe) since they would be based on the same group members (in this case, Asian countries), i.e. %c.

I have created pool objects (one for each region to identify their members), but I am not sure how to insert this information in the loop.

Thank you again.

Re: Aggregating Cross-Sections in Pools

Posted: Tue Aug 10, 2010 8:05 am
by EViews Gareth
There is probably a clever way using pools, but I'm not a pool fan and never use them as much as I should.

You could use string lists though. This code isn't tested, but the idea should work even if there is a mistake:

Code: Select all

%Asia = "BN FJ ID KH KP LA MM MN MY PG" %Americas = "CR CU DO GT JM MX NI SR TT" %Africa = "AO BF CV TD KM ET GA GN GW KE" for %r asia americas africa for %v GDP POP INF NER EXP IMP FDI series {%v}_{%r} = 0 %reglist = %{%r} for !i = 1 to @wcount(%reglist) %c = @word(%reglist,!i) {%v}_{%r} = {%v}_{%r} + {%v}_{%c} next next next next next next