Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible bug with function wofd()

    I think the function wofd() has a bug when it changes a date to its corresponding week. Here is what I got after running
    ge week = wofd(date)

    Please let me know if I was wrong. Thank you.

  • #2
    Absolutely no bug here. Stata's definition of weeks is that there are precisely 52 weeks in a year and that the first week always begins on 1 January.

    This is documented e.g. http://www.stata.com/help.cgi?week()

    It follows from these rules that the last week is always 8 or 9 days long, and in turn that the last week of the year will always include 30 December.

    There is a different question of whether this matches what you want otherwise, and the answer to that is often No.

    For much more discussion see e.g. http://www.stata-journal.com/sjpdf.h...iclenum=dm0052 and articles found by

    Code:
    search week, sj
    Please note our strong advice to show data or output using CODE delimiters, as here, and deprecating photo attachments. http://www.statalist.org/forums/help#stata

    Comment


    • #3
      Thank you, Nick. Now I see why.

      Comment


      • #4
        Xu,

        I wouldn't call it a bug per se. I don't see any documentation on this anywhere, but I suspect that StataCorp has a reason for this. We commonly think of a year having 52 weeks, but that is only 364 days, leaving one day extra (two in a leap year). We could call this extra day "Week 53" but apparently StataCorp thinks that would be confusing and/or inaccurate (since Week 53 is not a full week), so instead they include it with Week 52. You can imagine problems that would arise from trying to multiply weeks by 7 to get number of days if one of the weeks had less than seven days. Of course, with the current method, multiplying weeks by 7 is also problematic, although less so. This is more of a philosophical problem without a good solution, as week variables are probably not meant to be manipulated in that way.

        Note, as well, that it would be extremely difficult to change this now, since every week value since the end of 1960 would be affected. Do you have a particular reason for wanting the last day or two of the year to be "Week 53"?

        Regards,
        Joe

        Comment


        • #5
          Joe,

          Thank you for your answer. After reading the definition of weeks in Stata, I agree that it cannot be called as a bug. I have used some other methods to get the week variable that I wanted. I would like to change the post title to avoid other readers' confusion, but it seems that I cannot edit the title any more as soon as it's been posted.

          Best,
          Xu

          Comment

          Working...
          X