Statalist


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

Re: st: Re: Data management


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Re: Data management
Date   Mon, 11 May 2009 18:28:45 -0400

Try

 gen poststroke=stroke
 bys ptid (visit): replace poststroke=poststroke[_n-1]==1
 keep if poststroke


Hope this helps


Dr. Dilip K. Pandey wrote:
Hi.
I am working with hierarchical data.
There are several hospital visit by patients. My outcome of interest is stroke. Patient is diagnosed with stroke in one or other of hospital visit. I would like to exclude visits prior to diagnosis of first stroke (index hospitalization) but would keep informations on hospital visit after index hospitalization. Example of dataset is below:

Pt.ID    visit    stroke    ADMSN_DT
1               1    0        1-Feb-05
1               2    0        1-Apr-05
1               3    0        19-Apr-05
1               4    0        14-Oct-05
1               5    0        30-Oct-05
1               6    1        18-Nov-05
1               7    0        2-Dec-05
2               1    0        10-May-05
2               2    0        30-Nov-05
3               1    0        8-Nov-05
4               1    1        4-Mar-05
4               2    0        9-Jul-05
4               3    0        15-Sep-05
5               1    0        31-Aug-05
6               1    0        20-Jul-05
6               2    0        3-Oct-05
7               1    1        27-Nov-05
8               1    1        29-Jul-05
8               2    1        18-Oct-05
9               1    0        13-Mar-05
9               2    0        11-Jul-05
9               3    0        6-Sep-05
9               4    0    28-Nov-05
9               5    0    19-Dec-05
10             1    0    29-Mar-05
10             2    0        4-Mar-05
10             3    0    25-Jul-05
11             1    1    10-Dec-05
12             1    1    16-Jan-05
12             2    0    19-Jan-05
12             3    0    22-Feb-05


There are close to 800,000 hospitalizations to work with. Please suggest macro or stata program to drop observation (hospital visits) prior to index hospitalization but not after. Thanks
Dilip
*
*   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