Statalist


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

Re: st: First instance of starting and stopping drug


From   Svend Juul <[email protected]>
To   [email protected]
Subject   Re: st: First instance of starting and stopping drug
Date   Thu, 13 Mar 2008 13:26:30 +0100

Paul wrote:

We have a database of patients on and off a drug in the long form,  
some stopping before starting later. I want to do a survival analysis  
on the first instance of starting and stopping use under our care, but  
have difficulty isolating the first episode of use.

=============================================================

I assume that long form means something like this:

   clear
   input id timeon timeoff
   1 1 3
   1 6 7
   2 1 5
   2 6 9
   end

You want to keep the first treatment period for each id:

   by id (timeon), sort: generate incl = _n==1
   keep if incl==1
   sort id timeon
   list

        +------------------------------+
        | id   timeon   timeoff   incl |
        |------------------------------|
     1. |  1        1         3      1 |
     2. |  2        1         5      1 |
        +------------------------------+


Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone:  +45 8942 6090
Home:   +45 8693 7796
Email:  [email protected]
__________________________________________ 


*
*   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