Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: creating an array with hospitalization days


From   "Maria Montez" <montez@bu.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: creating an array with hospitalization days
Date   Tue, 8 Nov 2005 17:55:44 -0500

Nick,

you are correct and I'm thinking in SAS but I'm trying really hard to switch
into STATA!

My problem is that I need to figure out which records correspond to
overlapping hospitalizations so that I can deal with them. I do not want to
program case by case because it seems to me that I might end up with lots of
mistakes. In trying to find a mechanical way of doing this I decided that I
could create an array with the days in the year and then add up the arrays
corresponding to each patient. At the end each patient will have an array
and if I have a day that as a value greater than 1 than I know that I have
potential overlaps. I realize this is not the best way.

Ideally I would want to be able to create a variable with day and time
together because then I could easily just compare discharge time in one
record is smaller or bigger than admission time in the next record. But I
couldn't find such function.

I really didn't want to bother you with all this but I just got stuck.

Thanks, Maria

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of jean ries
Sent: Tuesday, November 08, 2005 4:44 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: creating an array with hospitalization days


Maria,

I think that our problem is best solved if you are using "long" instead
of "wide" data. But as Nick Cox has pointed out, you probably won't
need all these extra variables.

. gen begin = admitday - mdy(10,1,2000) + 1
. gen end = disday - mdy(10,1,2000) + 1
. expand 365
. sort study_id
. by study_id: gen daynumber = _n
. by study_id: gen day = inrange(daynumber,begin,end)
. reshape wide day , i(study_id) j(daynumber)


best wishes,

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


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