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
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: data management - days into weeks
Date
Wed, 7 Mar 2012 07:45:08 +0000
Or
gen week = ceil(day/7)
See also
SJ-3-4 dm0002 . . . . . . . . Stata tip 2: Building with floors and ceilings
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q4/03 SJ 3(4):446--447 (no commands)
tips for using floor() and ceil()
which is freely accessible to all. -search ceil- in Stata to get a
clickable link.
Nick
On Tue, Mar 6, 2012 at 11:57 PM, Phil Clayton
<[email protected]> wrote:
> How about:
> gen week=trunc((day-1)/7) + 1
On 07/03/2012, at 10:48 AM, Maria Cecilia Vieira da Silva wrote:
>> 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'.
*
* 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/