Statalist


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

RE: st: RE: Gap in treatment


From   PEREZ PEREZ JORGE EDUARDO <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: Gap in treatment
Date   Sat, 11 Jul 2009 22:49:03 +0000

It seems like the dates are not in the correct format. How did you convert the dates? I'd import the original dataset leaving the date as a string variable, then do the following:

gen date2=daily(date, "DMY")
format date2 %td
drop date
ren date2 date

And now the previous code should work

_________________________
Jorge Eduardo Pérez Pérez

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gary Walker
Sent: sábado, 11 de julio de 2009 05:21 p.m.
To: [email protected]
Subject: Re: st: RE: Gap in treatment

Actually I forgot I converted the dates before importing into stata.
Now it is like this:

 Patient     days chemo drug
 A          45           X
 A         6745         Y
 A          645          X
 B          345          Z
 B          343          X
 C          5667        Y
 C          123          X
 C          5              Z


When I try:
sort patient days

it is not in the correct order.  it lists them like this:

101
178
201
255
13
54
78

Why is it not sorting them correctly?



On Sat, Jul 11, 2009 at 3:11 PM, PEREZ PEREZ JORGE
EDUARDO<[email protected]> wrote:
> Make sure your date has the proper format (i.e %td), then:
>
> sort patient date
> by patient: gen gap=date[_n]-date[_n-1]
> by patient: egen maxgap=max(gap)
>
> Hope this helps,
> _________________________
> Jorge Eduardo Pérez Pérez
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Gary Walker
> Sent: sábado, 11 de julio de 2009 04:45 p.m.
> To: [email protected]
> Subject: st: Gap in treatment
>
> I have a dataset of each administration of chemotherapy for a number
> of patients, i.e.:
>
> Patient     date      chemo drug
> A          7/1/2009    X
> A         4/1/2009    Y
> A          1/1/2008    X
> B          7/1/2009    Z
> B          1/1/2008    X
> C          7/1/2009    Y
> C          4/1/2009    X
> C          1/1/2008    Z
>
> I want to calculate the biggest gap in treatment for each patient. In
> other words, what was the maximum amount of time between treatments
> for each patients.  Any ideas on how to do this?
> *
> *   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/
>



--
Gary Walker

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