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" <>
To   <>
Subject   RE: st: creating an array with hospitalization days
Date   Tue, 8 Nov 2005 17:55:44 -0500


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-----
[]On Behalf Of jean ries
Sent: Tuesday, November 08, 2005 4:44 PM
Subject: Re: st: creating an array with hospitalization days


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,

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index