Page 1 of 1

looping to create series names

Posted: Mon Feb 09, 2009 7:29 am
by eviewscg
Hi,
I am trying to to make a loop where the name of the series is looped by an alpha series for the series names and a group for definition of the series. I can get the second half of this to work, but I am unable to find a way for the series names themselves to loop. Basically, I want to create a bunch of series prwds_*, prwdh_*, etc where * is iso country codes for about 62 countries. Here is an example of what I am trying:

for !j=1 to 62
series prpws_isocode(!j)= prpws_usd(!j) *xr_us(!j)
series prpwh_isocode(!j)= prpwh_usd(!j) *xr_us(!j)
series prchs_isocode(!j)= prchs_usd(!j) *xr_us(!j)
series prchh_isocode(!j)= prch_usd(!j) *xr_us(!j)

where isocode is my alpha series containing br, cl, etc
prpws_usd is a group containing pws_br, pws_cl, etc
xr_us is a group containing xrbrus, xrclus, etc
and the groups are all alphabatized by the country code, so the same element (ex: 3rd) in each group (or isocode series) all refer to the same country

Obviously, I know I can write out all 248 (62*4) series names by hand and just loop for the RH side, but I would really prefer to avoid this at all costs from both a time and an ability to change easily standpoint. Thanks for any help!

Re: looping to create series names

Posted: Mon Feb 09, 2009 9:07 am
by EViews Gareth

Code: Select all

for !j=1 to 62 %name = "prpws_" + isocode(!j) series %name = prpws_usd(!j) *xr_us(!j)
Or something along those lines...

Re: looping to create series names

Posted: Mon Feb 09, 2009 9:17 am
by eviewscg
Thanks a lot! I will give that a try.

Re: looping to create series names

Posted: Mon Feb 09, 2009 9:33 am
by eviewscg
Using the code you suggested, I am not getting the error:

Can not assign string expression to numeric variable in "SERIES %NAME =PRPWS_USD(1)*XR_US(1)"


Any suggestions?

Re: looping to create series names

Posted: Mon Feb 09, 2009 9:56 am
by EViews Gareth
Sorry, forgot the braces:

series {%name} = ....

Re: looping to create series names

Posted: Mon Feb 09, 2009 10:03 am
by eviewscg
Thank you very much! I have it working now. Much appreciation!!!