week numbering
Moderators: EViews Gareth, EViews Moderator
week numbering
It would be helpful if EViews would implement at least one of the standard week numbering systems (US or ISO 8601) instead of just starting at Jan 1 and every 7 days thereafter. At this time, it would probably be best if both those standards were supported. For now, I will have to do that type of calculation using SQL Server and bring the values over to EViews.
-
- EViews Developer
- Posts: 161
- Joined: Wed Sep 17, 2008 10:39 am
Re: week numbering
The good news is that EViews 6 already has the ISO 8601 week as an undocumented feature: use 'wi' as the time unit argument in @datepart:
The bad news is that there's no way to get at the matching ISO 8601 week numbering year (since the calendar year is not necessarily the ISO week year). I might be able to look into this if it is important to you.
As far as the US week numbering goes, I'm not sure exactly what the rules are meant to be for the first and last days of the year, but you might be after something like this:
I can explain the details if you want, but it's basically finding how many days since the start of the year and what day of the week the first day of the year was on then using these results to number weeks from the first Sunday. Values of 0 and 53 are possible at the start and end of the year.
Code: Select all
show @datepart(@date, "wi")
The bad news is that there's no way to get at the matching ISO 8601 week numbering year (since the calendar year is not necessarily the ISO week year). I might be able to look into this if it is important to you.
As far as the US week numbering goes, I'm not sure exactly what the rules are meant to be for the first and last days of the year, but you might be after something like this:
Code: Select all
show @floor((@date-@datefloor(@date,"year") + @datepart(@datefloor(@date,"year"),"w")) / 7)
I can explain the details if you want, but it's basically finding how many days since the start of the year and what day of the week the first day of the year was on then using these results to number weeks from the first Sunday. Values of 0 and 53 are possible at the start and end of the year.
Re: week numbering
Thanks, Chris. I guess my next suggestion would be to document those undocumented features.
And, yeah, the ISO year would really be needed in order to use the ISO week effectively. If that capability could be fully developed and documented with a future update, I'm sure there are people who would appreciate it.
I think I am going to go with the US system for my current project, but so far I have not seen a reference to a system with a "week 0". I think the first week, partial or full, is always 1 and there can sometimes be a partial week 54 at the end.
And, yeah, the ISO year would really be needed in order to use the ISO week effectively. If that capability could be fully developed and documented with a future update, I'm sure there are people who would appreciate it.
I think I am going to go with the US system for my current project, but so far I have not seen a reference to a system with a "week 0". I think the first week, partial or full, is always 1 and there can sometimes be a partial week 54 at the end.
-
- EViews Developer
- Posts: 161
- Joined: Wed Sep 17, 2008 10:39 am
Re: week numbering
Here's the adjustment for always numbering weeks starting from 1 (and sometimes going up to 54)
Note that @mod(weekday,7) is a convenient (if somewhat cryptic) way of changing weekday 7 to 0 while leaving the other weekdays unchanged.
Code: Select all
show @floor((@date-@datefloor(@date,"year") + @mod(@datepart(@datefloor(@date,"year"),"w"),7)) /7)+1
Note that @mod(weekday,7) is a convenient (if somewhat cryptic) way of changing weekday 7 to 0 while leaving the other weekdays unchanged.
Re: week numbering
Thanks, that works.
Return to “Suggestions and Requests”
Who is online
Users browsing this forum: No registered users and 24 guests