MTOS

For questions regarding programming in the EViews programming language.

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

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: MTOS

Postby EViews Steve » Thu Oct 04, 2018 6:40 am

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

dhityayl
Posts: 14
Joined: Sun Aug 26, 2018 10:29 pm

Re: MTOS

Postby dhityayl » Thu Oct 04, 2018 6:49 am

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
Attachments
1301.T.csv
(23.47 KiB) Downloaded 428 times

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: MTOS

Postby EViews Steve » Thu Oct 04, 2018 6:54 am

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

dhityayl
Posts: 14
Joined: Sun Aug 26, 2018 10:29 pm

Re: MTOS

Postby dhityayl » Thu Oct 04, 2018 6:58 am

Hi Steve,
The code works well for me.
Thank you so much for the help.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests