using brackets around a % variable

For questions regarding programming in the EViews programming language.

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

AnnH
Posts: 22
Joined: Fri Mar 09, 2012 11:42 am

using brackets around a % variable

Postby AnnH » Fri Jun 29, 2012 7:59 am

I have a program that worked in eviews 4, trying to get everything working in eviews 7.
The problem I have is when I write a file to excel and want the name to reflect the list that has the variables currently being written, I try the following:
FOR %j ListA ListB

WRITE(t=xls, a2, nodates, names) "c:\model\data\Output\US{!j}A" year qtr {%s}

I get 1 file written out named: US{!j}A.XLS

when there should be 2, named USListAA.xls and USlistBA.xls

(the %s is defined in other code and works fine, the data in the file writes correctly, it just doesn't name properly)

I'm pretty sure I have a problem with the way I have the {!j} in the write statement, but can't figure out what.

Thanks for any ideas.

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

Re: using brackets around a % variable

Postby EViews Gareth » Fri Jun 29, 2012 10:04 am

You should be using wfsave rather than write, but apart from that, you can fix your bug with:

Code: Select all

%filename = "c:\model\data\output\us" + @str(!j) + "A" WRITE(t=xls, a2, nodates, names) {%filename} year qtr {%s}

AnnH
Posts: 22
Joined: Fri Mar 09, 2012 11:42 am

Re: using brackets around a % variable

Postby AnnH » Fri Jun 29, 2012 11:30 am

That works - thank you!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests