Weekly data: calendar week vs. Stata weeks

In my dataset, I have information on a number of workers for each week. The raw data I receive (no Stata format) contains information on the year and the week (1, 2, …, 52). Here, a week is defined as the first week of a year which has at least 4 days in January. E.g., the week 1/2009 starts already on December 29, 2008. A result of that is that for some years, a year has 53 calendar weeks.

Stata, however, uses a different system: here, the first week starts on January 1, irrespective of the week day. Weeks are thus not counted from Monday to Sunday (or Sunday to Saturday), but differently for each year. In addition, Stata never has 53 weeks, but rather extends the last (52th) week to 8 or 9 days.

The problem comes up if you have daily data and want to merge it with weekly information (by collapsing it by week and then use –merge–). If you simply collapse the data by (Stata) week, and merge it, you will always merge overlapping weeks, but never exact matching weeks

There doesn’t seem to be a really proper solution. In case you only have a, there is a small trick which solves the problem: simply shift the daily information by a the number of days that the first week in Stata is lagging behind the first week in a normal calendar: for 2009, a normal calendar starts its first week on December 29, 2008 while Stata does the same on January 01, 2009. Simply replace the the day information starting by December 29, 2008 by 3. Stata will then interpret the day-information as January 1, 2009, January 2, and so forth.

In case you have more years: for 2008, add “1”; for 2007, Stata and normal calendar weeks are the same.

also see the other posts on dates: here

Leave a Reply