I have a code for loop programming below. So basically i loop a rolling regression and after that i want to save to excel.
The code below works for the looping itself (without wfsave), but in the middle of the looping with wfsave, the loop failed. The error message is : File IO failed for file 'Could not create entry in zip file.' in "WFSAVE(TYPE=EXCELXML) "C:\USERS\DHITYA\DESKTOP\2\2001.T.CSV.XLSX" @KEEP DATE RETURN G1".
Is there something wrong with the code? It works before with just 2 files, but when i do 50 files, it failed.
If i want to try running the program again with different data, i should create a new destination folder to save my file, but it will failed again in the middle of the loop.
Code: Select all
%filenames = @wdir("D:\Thesis_Loop\2002_2\dataset")
for !k=1 to @wcount(%filenames)
%file = @word(%filenames, !k)
!window = 60
!step = 1
!length = @obsrange
!nrolls = @round((!length-!window+1)/!step)
for !i = 1 to !length-!window+1-!step step !step
smpl @first+!i-1 @first+!i+!window-2
equation eq1.ls return c indeks mkt_rf smb hml
matrix r1=@transpose (coefmat!k)
group g1 rbc rbindeks rbmkt rbsmb rbhml
sample s1 @first+59 @last
mtos(r1, g1, s1)
if @isobject("s1") then
%path = "C:\Users\Dhitya\Desktop\2\" + %file + ".xlsx"
wfsave(type=excelxml) %path @keep date return g1