week numbering

For making suggestions and/or requests for new features you'd like added to EViews.

Moderators: EViews Gareth, EViews Moderator

jsheldon
Posts: 7
Joined: Tue Sep 30, 2008 8:08 am
Location: USA

week numbering

Postby jsheldon » Tue Feb 17, 2009 3:26 pm

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 Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: week numbering

Postby EViews Chris » Tue Feb 17, 2009 5:46 pm

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:

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.

jsheldon
Posts: 7
Joined: Tue Sep 30, 2008 8:08 am
Location: USA

Re: week numbering

Postby jsheldon » Wed Feb 18, 2009 7:59 am

Thanks, Chris. I guess my next suggestion would be to document those undocumented features. :wink:
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 Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: week numbering

Postby EViews Chris » Wed Feb 18, 2009 11:34 am

Here's the adjustment for always numbering weeks starting from 1 (and sometimes going up to 54)

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.

jsheldon
Posts: 7
Joined: Tue Sep 30, 2008 8:08 am
Location: USA

Re: week numbering

Postby jsheldon » Wed Feb 18, 2009 11:52 am

Thanks, that works.


Return to “Suggestions and Requests”

Who is online

Users browsing this forum: No registered users and 24 guests