Page 2 of 2

Re: MTOS

Posted: Thu Oct 04, 2018 6:40 am
by EViews Steve
Try creating a separate %path string value first:

Code: Select all

mtos(r1, g1, s1) if @isobject("s1") then delete s1 endif %path = "C:\Users\Dhitya\Desktop\test\" + %file wfsave(type=excelxml) %path @keep date return g1

Re: MTOS

Posted: Thu Oct 04, 2018 6:49 am
by dhityayl
Hi Steve, I've tried that, but the file saved to my folder is not in excel but in csv file and i don't think that the file saved is the right series. is there anything else wrong with my code? I attached the csv file saved to my folder in this post.
Thankyou

Code: Select all

cd "c:\Users\Dhitya\Desktop\Program\dataset" %filenames = @wdir("c:\Users\Dhitya\Desktop\Program\dataset") for !k=1 to @wcount(%filenames) %file = @word(%filenames, !k) wfopen %file import c:\Users\Dhitya\Desktop\Program\dataset\index\Indeks_2002.csv import c:\Users\Dhitya\Desktop\Program\dataset\index\FF3_2002.csv genr return=(((close-close(-1))/close(-1))*100)-rf !window = 60 !step = 1 !length = @obsrange equation eq1 !nrolls = @round((!length-!window+1)/!step) matrix(5,!nrolls) coefmat!k !j=0 for !i = 1 to !length-!window+1-!step step !step !j=!j+1 smpl @first+!i-1 @first+!i+!window-2 equation eq1.ls return c indeks mkt_rf smb hml colplace(coefmat!k, eq1.@coefs,!j) matrix(!nrolls,5) r1 matrix r1=@transpose (coefmat!k) series rbc series rbindeks series rbmkt series rbsmb series rbhml group g1 rbc rbindeks rbmkt rbsmb rbhml sample s1 @first+59 @last mtos(r1, g1, s1) if @isobject("s1") then delete s1 endif %path = "C:\Users\Dhitya\Desktop\test\" + %file wfsave(type=excelxml) %path @keep date return g1 'close @all next next

Re: MTOS

Posted: Thu Oct 04, 2018 6:54 am
by EViews Steve
if %filename was originally a name with a .csv file extension, then the resulting new excel file will also have that name since you told EViews to use that name. The file is still an excelxml file format, but the extension is just wrong.

If you rename the file to have an xlsx file extension, then you'll be able to open it in excel just fine.

Try this bit of code next:

Code: Select all

%path = "C:\Users\Dhitya\Desktop\test\" + %file + ".xlsx" wfsave(type=excelxml) %path @keep date return g1

Re: MTOS

Posted: Thu Oct 04, 2018 6:58 am
by dhityayl
Hi Steve,
The code works well for me.
Thank you so much for the help.