Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Week() Function


From   "Brian P. Poi" <bpoi@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Week() Function
Date   Wed, 25 Jul 2007 15:01:10 -0500 (CDT)

On Wed, 25 Jul 2007, Eric G. Wruck wrote:

I was trying to use the week function to graph weekly totals. However, I get some squirrelly results. Am I doing something wrong or have I uncovered a bug?


. gen week = week(date2)

. format week %tw

. l date2 week

+---------------------+
| date2 week |
|---------------------|
1. | 16jul2007 1960w30 |
2. | 17jul2007 1960w30 |
+---------------------+

Eric,

I suspect you want to use the wofd() function instead:

   . gen week2 = wofd(date2)
   . format week2 %tw
   . list date2 week2

     +---------------------+
     |     date2     week2 |
     |---------------------|
  1. | 16jul2007   2007w29 |
  2. | 17jul2007   2007w29 |
     +---------------------+


Both those dates occurred in the 29th week of 2007.

   -- Brian Poi
      bpoi@stata.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index