Looping in Fetch command

For questions regarding programming in the EViews programming language.

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

ttocont
Posts: 7
Joined: Mon Aug 26, 2013 7:42 am

Looping in Fetch command

Postby ttocont » Mon Nov 11, 2013 10:10 am

I'm trying to loop through two strings in order to download series via Macrobond but can't figure out how to get the quotations marks and spaces correctly.

So for example, instead of:
fetch(d=mb) "ih:bl:ussw2 bgn curncy" "ih:bl:cdsw2 bgn curncy" "ih:bl:ussw5 bgn curncy" "ih:bl:cdsw5 bgn curncy" "ih:bl:ussw10 bgn curncy" "ih:bl:cdsw10 bgn curncy"

I am trying to do something like:

%BBG_swaps = "ussw cdsw"
%BBG_matyr = "2 5 10"
%bbg_start ="ih:bl:"
%bbg_fxend = " bgn curncy "

for %i {%BBG_swaps}
for %j {%BBG_matyr}
fetch(d=mb) {%bbg_start}{%i}{%j}{%bbg_fxend}
next
next


But from what I can tell of the error message, that seems to want to put a quote around the entire fetch command like:
"fetch(d=mb) "ih:bl:ussw2 bgn curncy"

Is there way to program this?

Thanks

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

Re: Looping in Fetch command

Postby EViews Gareth » Mon Nov 11, 2013 10:22 am

What you are doing looks like it should work.

ttocont
Posts: 7
Joined: Mon Aug 26, 2013 7:42 am

Re: Looping in Fetch command

Postby ttocont » Mon Nov 11, 2013 10:30 am

When I run it I get the error message:

2 Objects were not found: MB::IH:BL:USSW2 MB::CURNCY in "FETCH(D=MB) IH:BL:USSW2 BGN CURNCY".

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

Re: Looping in Fetch command

Postby EViews Gareth » Mon Nov 11, 2013 10:45 am

Try this:

Code: Select all

for %i {%BBG_swaps} for %j {%BBG_matyr} %term = %bbg_start + %i + %j + %bbg_fxend fetch(d=mb) %term next next

ttocont
Posts: 7
Joined: Mon Aug 26, 2013 7:42 am

Re: Looping in Fetch command

Postby ttocont » Tue Nov 12, 2013 12:41 am

That worked like a charm. Thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests