Statalist


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

st: RE: RE: RE : R: Intervals time


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE : R: Intervals time
Date   Tue, 22 Apr 2008 16:18:26 +0100

Correction: 

gen duration = end - begin + 1
drop if treat == 0
gen long obs = _n 
expand dur
bysort id obs : replace begin = begin[_n-1] + 1 if _n > 1
l
contract id begin

I get 3 treatments on 16 May.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 22 April 2008 16:06
To: [email protected]
Subject: st: RE: RE : R: Intervals time

Is this what you want? 

 gen duration = end - begin + 1
 drop if treat == 0
 expand dur
 bysort id begin : replace begin = begin[_n-1] + 1 if _n > 1
 l
 contract id begin

Nick
[email protected] 

[email protected]

Thank you Carlo, but this will not answer my question.
Maybe it was not clear !

Sata are as follows:

id	   begin	      end	   treat
1	04 Apr 2006	  06 Apr 2006	1
1	05 Apr 2006	  09 Apr 2006	0
1	08 Apr 2006	  12 Apr 2006	1
2	15 May 2006	  16 May 2006	1
2	16 May 2006	  24 May 2006	1
2	16 May 2006	  17 May 2006	1 

Subject 2 has only one treatment from 15 May 2006 to 16 May 2006.
Then he has two treatments from 16 May 2006 to 17 May 2006, and one
treatment
from 18 May 2006 to 24 May 2006.

This is the result I want to find !


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index