Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: data management - days into weeks


From   Phil Clayton <philclayton@internode.on.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: data management - days into weeks
Date   Wed, 7 Mar 2012 10:57:17 +1100

How about:
gen week=trunc((day-1)/7) + 1

Phil

On 07/03/2012, at 10:48 AM, Maria Cecilia Vieira da Silva wrote:

> Hello all,
> In my data set I have "day", a variable that indicates the day of treatment of a patient. Example:
> 
> Patient=1
> 
> Day=5
> Outcome x1=6
> Outcome x2=0.5
> 
> Day=10
> Outcome x1=5
> Outcome x2=0.6
> 
> I would like to create a variable "week", where week=1 if day<=7; week=2 if 7<day<=14 and so on.
> Any suggestion about how to create "week" without my having to write the conditions for each week of the year up to week 52?
> The date functions do not help me because my data set does not contain 'dates'.
> 
> Thanks,
> Maria Cecilia
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index