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.
Aggregating Cross-Sections in Pools
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Aggregating Cross-Sections in Pools
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
Follow us on Twitter @IHSEViews
Re: Aggregating Cross-Sections in Pools
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.
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.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Aggregating Cross-Sections in Pools
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:
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
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 8 guests