Calculating Daily Census based on entry and exit dates

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculating Daily Census based on entry and exit dates

ariel barak
Hi Everyone,

I have data on two facilities and I'd like to know for each day between the
earliest datein and the latest dateout how many individuals were in the
facility so I can compute a daily census. Please note that some individuals
are admitted towards the end of 2007 and released in 2008 but the length of
stay is never longer than one year.

There are always at least 10 individuals in each of the two facilities, so
there will never be a day where the daily census is 0. I'm not sure what the
solution should look like but basically I would like to create variables
with a 1 if the individual was in the facility on that day and a 0 if they
were not. I could then aggregate on the facility and sum the 1's for a given
date to get the total number of individuals in the facility.

So with the sample data below, the earliest date is 12/5/2007 and the latest
date is 5/25/2008 - so I would want a variable for each day from 12/5/2007
to 5/25/2008 with 1's and 0's properly placed to denote whether the
individual was in the facility or not. So for day1 (Dec 5 2007) only id 1
would have a 1 for that day while for day93 (Mar 6 2008) id 2,3,4, and 5
would all have 1's indicating that ids 2-5 were in a facility on March 6th,
2008.

*Sample Data.
DATA LIST LIST /id(F8) facility (A7) datein(ADATE) dateout(ADATE).
BEGIN DATA
1 Shelter 12/5/2007 2/9/2008
2 Secure 2/7/2008 3/7/2008
3 Secure 3/2/2008 5/25/2008
4 Shelter 2/1/2008 4/4/2008
5 Shelter 1/31/2008 4/1/2008
END DATA.

Thanks in advance!

-Ari

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Daily Census based on entry and exit dates

Richard Ristow
At 10:24 AM 8/12/2008, Ariel Barak wrote:

>I have data on two facilities and I'd like to know for each day
>between the earliest datein and the latest dateout how many
>individuals were in the facility

This comes up from time to time. Rather than re-post the logic, let
me refer you to the archives for recent thread "daily number of
patients", Thu, 10 Jul 2008 and following.

In that thread, Gene Maguin posted a solution using a vector, and I
posted a (logically similar) one using XSAVE. See if either of those
serve your purpose.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Daily Census based on entry and exit dates

ariel barak
This syntax from Richard's previous solution works perfectly...but I hadn't
ever used the File Handle command he used, so I specified a specific
location in the xsave and get file commands instead.

Thanks to Richard and Gene who helped me track down the proper posting!

-Ariel


NUMERIC Today            (DATE11)
   /AdmitToday DischToday (F2).
VAR LABEL
    Today      "Date, within patient's hospital stay"
    AdmitToday "Flag: Patient admitted this date"
    DischToday "Flag: Patient discharged this date".


LOOP  Today = datein to dateout BY TIME.DAYS(1).
.  COMPUTE AdmitToday = (Today EQ AdmitDate).
.  COMPUTE DischToday = (Today EQ DischDate).
.  XSAVE OUTFILE=UNROLL
    /KEEP=PatientID Today AdmitToday DischToday.
END LOOP.
EXECUTE  /* this one is needed */.


GET FILE=UNROLL.


.  /**/  LIST  /*-*/.


AGGREGATE OUTFILE=*
    /BREAK  = Today
    /Patients   "Number of patients on this date" = NU
    /Admits     "Number of admissions on this date" = SUM(AdmitToday)
    /Discharges "Number of discharges on this date" = SUM(DischToday).


FORMATS Patients Admits Discharges (F3).



On Tue, Aug 12, 2008 at 1:40 PM, Richard Ristow <[hidden email]>wrote:

> At 10:24 AM 8/12/2008, Ariel Barak wrote:
>
>  I have data on two facilities and I'd like to know for each day between
>> the earliest datein and the latest dateout how many individuals were in the
>> facility
>>
>
> This comes up from time to time. Rather than re-post the logic, let me
> refer you to the archives for recent thread "daily number of patients", Thu,
> 10 Jul 2008 and following.
>
> In that thread, Gene Maguin posted a solution using a vector, and I posted
> a (logically similar) one using XSAVE. See if either of those serve your
> purpose.
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD