Hi all,
I'm attempting to convert daily data, to weekly data (week starting friday). However, no matter how I structure my weekly data workfile (week starting monday, friday, etc), it treats the data as if the week is starting on a Tuesday.
I have attached the relevant workfiles and prg to this post.
The conversion is towards the bottom of the PRG, before the stop command.
Any help is appreciated.
Thanks!
Bob
Daily to weekly conversion
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Daily to weekly conversion
- Attachments
-
- demand_data.prg
- (6.44 KiB) Downloaded 325 times
-
- weekly.wf1
- (60.71 KiB) Downloaded 290 times
-
- sql_demand.wf1
- (1007.49 KiB) Downloaded 305 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Daily to weekly conversion
Starting the week on a Friday seems to work:
Code: Select all
close @wf
wfopen sql_demand
wfcreate(wf=weekly2, page=w) w 2019/10/04 2020/10/20
copy sql_demand::data\dindmclo weekly2::w\dindmclo
wfselect sql_demand
pageselect data
smpl if @weekday = 4 'only show thursday's
group g @movav(dindmclo, 7) ' display 7 day moving average (i.e. the weekly average, starting on a friday)
show g
wfselect weekly2
show dindmclo
Re: Daily to weekly conversion
Thank you for your reply. Your snippet of code does show that it works. However, the prg I included does not.
If I use the default starting day (or set it to friday), the dates for the week and the average do not match your code.
Could it have something to do with my smpl setting in creating the weekly wf? That seems to be the only place where our code differs.
Thanks,
Bob
If I use the default starting day (or set it to friday), the dates for the week and the average do not match your code.
Could it have something to do with my smpl setting in creating the weekly wf? That seems to be the only place where our code differs.
Thanks,
Bob
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Daily to weekly conversion
What do you mean by sample setting?
Re: Daily to weekly conversion
If I copy and paste "2019/10/04 2020/10/20" as the smpl period in my code it works fine.
If I leave my string reference %start %end, the averages are thrown off.
I just recoded the prg so that those strings are declared as:
%start = @str(@dateval(@date)-364)
%end = @str(@dateval(@date)+14)
The issue is with the first part of the smpl period.
wfcreate(wf=weekly) w 2019/10/4 %end yield the correct average
wfcreate(wf=weekly) w %start %end yield an incorrect average
in this instance, %start = "2020/10/8". I'm assuming the truncated first week is throwing off the entire conversion. Does this make sense?
Thanks,
Bob
If I leave my string reference %start %end, the averages are thrown off.
I just recoded the prg so that those strings are declared as:
%start = @str(@dateval(@date)-364)
%end = @str(@dateval(@date)+14)
The issue is with the first part of the smpl period.
wfcreate(wf=weekly) w 2019/10/4 %end yield the correct average
wfcreate(wf=weekly) w %start %end yield an incorrect average
in this instance, %start = "2020/10/8". I'm assuming the truncated first week is throwing off the entire conversion. Does this make sense?
Thanks,
Bob
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Daily to weekly conversion
Ah, that's not a sample.
But, when you create a weekly workfile the start date specifies the day of the week the workfile begins on. So if you want your weeks to start on a Friday, you have to use a start date of a Friday.
But, when you create a weekly workfile the start date specifies the day of the week the workfile begins on. So if you want your weeks to start on a Friday, you have to use a start date of a Friday.
Re: Daily to weekly conversion
This is very helpful. Thank you!
Who is online
Users browsing this forum: No registered users and 1 guest
