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/