Page 1 of 1

Looping through files in a folder

Posted: Mon Feb 13, 2012 1:07 pm
by mike_d
Hi, I am new to eviews and am simply trying to execute a peice of code on various files. I cannot seem to figure out how to properly insert the for loop number into the wfopen statement. I can open each file on its own by writing the full pathname out so that is not my problem. I have tried to create a matrix that is filled with the value 'i' on each loop (1 to 6 in this case) and could not get that to work either. I have posted my most recent attempt. Any guidance would be greatly appreciated.



cd \\Client\E$\Database
wfcreate (wf = issue) u 3131

for !i = 1 to 6
matrix(6,1) issue_num
issue_num(!i,1) = @str(!i)

wfopen "\\Client\E$\Database\Bond" + @str(!i) + ".xlsx" '' not working
freeze(uroottest_cds_spread) cds_spread.uroot(adf,const)
freeze(uroottest_FITCH_RATE ) FITCH_RATE .uroot(adf,const)
freeze(descriptives_CDS) CDS_SPREAD.stats
freeze(descriptives_Fitch) FITCH_RATE.stats

'''save results




next

Looping through files in a folder

Posted: Mon Feb 13, 2012 1:46 pm
by EViews Gareth
You can't build the full file name up as part of the wfopen command. Build it up in a temporary string first then use that temp string in wfopen.

Re: Looping through files in a folder

Posted: Mon Feb 13, 2012 1:55 pm
by mike_d
Thanks so much for the speedy reply. Only took a few minutes to figure out exactly how to do that. Thanks again!