Page 1 of 1

using brackets around a % variable

Posted: Fri Jun 29, 2012 7:59 am
by AnnH
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.

Re: using brackets around a % variable

Posted: Fri Jun 29, 2012 10:04 am
by EViews Gareth
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}

Re: using brackets around a % variable

Posted: Fri Jun 29, 2012 11:30 am
by AnnH
That works - thank you!