Statalist


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

st: Re: Re: Data management


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: Data management
Date   Tue, 12 May 2009 08:44:09 +0200

<>

You simply drop the ones where the (running) -sum- of the dummy is still below 1


***
clear*

input PtID    visit    stroke   str12 ADMSNDT
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
end

gen date=date(ADMSNDT, "DM20Y")
format date %tdMonth_DD,_CCYY
compress

//before
list, noobs

//drop before stroke
bys PtID (visit): drop if sum(stroke)<1

//after
list , noobs
***


HTH
Martin
_______________
----- Original Message ----- From: "Dr. Dilip K. Pandey" <[email protected]>
To: <[email protected]>
Sent: Tuesday, May 12, 2009 12:19 AM
Subject: st: Re: Data management


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