Page 1 of 1

Running a For loop over the read data command (EV 6)

Posted: Wed Apr 21, 2010 2:39 pm
by nadja123
Hi there,

I would be grateful for helping with this. The program is supposed to execute the same set of commands in 10 workfiles (each workfile represents one country).

I got stuck at line 3, where I try to automatize the import of data. The three series are arranged in an Excel file, on the same sheet, and follow after each other: for the first workfile (country) I need rows 2:40, for the second 41:79, etc. (every time 39 rows).

I tried to check out the help file and also the programming examples at this forum, but somehow I still have no idea how to indicate the data cell, so that the for loop can run over it.

Code: Select all

for !j = 1 to 10 wfcreate(wf=country{!j} ) q 2000q1 2009q3 read(c{2+(!j-1)*39}, s=data) file.xls series1 series2 series3 next
Many thanks for helping!!

Re: Running a For loop over the read data command (EV 6)

Posted: Wed Apr 21, 2010 2:49 pm
by EViews Gareth
Without trying it myself, you probably just need to compute the position outside of the read command:

Code: Select all

for !j = 1 to 10 wfcreate(wf=country{!j} ) q 2000q1 2009q3 !pos = 2+(!j-1)*39 read(c{!pos}, s=data) file.xls series1 series2 series3 next

Re: Running a For loop over the read data command (EV 6)

Posted: Wed Apr 21, 2010 2:57 pm
by nadja123
It works just fine, thanks a lot.

May I add another question? Is there any command to rename a workfile that is stored in the default directory? I tried the rename command, but it seems to work just for objects within a workfile... Or maybe I am wrong? Thanks.

Re: Running a For loop over the read data command (EV 6)

Posted: Wed Apr 21, 2010 3:08 pm
by EViews Gareth
You can do it with a DOS command using the shell command in EViews, or you could just open the workfile, then save it under a different name.

Re: Running a For loop over the read data command (EV 6)

Posted: Thu Apr 22, 2010 4:12 am
by nadja123
I am sorry, I have no idea what a DOS command looks like. Is it please possible to give an example? For the case I'd need to rename many workfiles at once, doing it manually is a bid tiresome. Thanks!

Re: Running a For loop over the read data command (EV 6)

Posted: Thu Apr 22, 2010 8:03 am
by EViews Gareth
Quick bit of Googling indicates that the DOS rename command is rename. Thus something like:

Code: Select all

shell rename c:\temp\mydata.wf1 mydata2.wf1