Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: data management - days into weeks


From   Phil Clayton <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index