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

For questions regarding programming in the EViews programming language.

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

nadja123
Posts: 72
Joined: Thu Aug 06, 2009 10:43 am

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

Postby nadja123 » Wed Apr 21, 2010 2:39 pm

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!!

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

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

Postby EViews Gareth » Wed Apr 21, 2010 2:49 pm

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

nadja123
Posts: 72
Joined: Thu Aug 06, 2009 10:43 am

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

Postby nadja123 » Wed Apr 21, 2010 2:57 pm

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.

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

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

Postby EViews Gareth » Wed Apr 21, 2010 3:08 pm

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.

nadja123
Posts: 72
Joined: Thu Aug 06, 2009 10:43 am

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

Postby nadja123 » Thu Apr 22, 2010 4:12 am

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!

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

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

Postby EViews Gareth » Thu Apr 22, 2010 8:03 am

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests