daily number of patients

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

daily number of patients

Leo Bakker
Hi Everyone,

I hope someone can help me with this one.
I have a lot of patients with an admission and dischargedate (dd-mm-yyyy).
What I want to calculate is how many patients there were on each day of
the year (occupied beds), and how many got in and out each day (turn over).
I know it can be done in SPSS, but i can't see how.

Thanks,
Leo

=====================
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: daily number of patients

Lemon, John S.
Leo

A quick and dirty answer for the turnover is to do a frequency on admission date and discharge date - when / if I get a quiet moment from students I'll see if I can address the first part which is slightly more complex.

Best Wishes

John S. Lemon
Student Liaison Officer
Directorate of Information Technology (DIT) - University of Aberdeen
Edward Wright Building: Room G51
Tel:  +44 1224 273350
Fax: +44 1224 273372



> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Leo Bakker
> Sent: Thursday, July 10, 2008 8:22 AM
> To: [hidden email]
> Subject: daily number of patients
>
> Hi Everyone,
>
> I hope someone can help me with this one.
> I have a lot of patients with an admission and dischargedate (dd-mm-yyyy).
> What I want to calculate is how many patients there were on each day of
> the year (occupied beds), and how many got in and out each day (turn over).
> I know it can be done in SPSS, but i can't see how.
>
> Thanks,
> Leo
>
> =====================
> 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


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
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: daily number of patients

Leo Bakker-2
John,

If tried that.
Problem is that I need both numbers, in and off, together.
With a frequency I get two large separate tables without the possibility to
calculate a mean and max.

Leo


-----Oorspronkelijk bericht-----
Van: Lemon, John S. [mailto:[hidden email]]
Verzonden: donderdag 10 juli 2008 9:30
Aan: 'Leo Bakker'; [hidden email]
Onderwerp: RE: daily number of patients

Leo

A quick and dirty answer for the turnover is to do a frequency on admission
date and discharge date - when / if I get a quiet moment from students I'll
see if I can address the first part which is slightly more complex.

Best Wishes

John S. Lemon
Student Liaison Officer
Directorate of Information Technology (DIT) - University of Aberdeen
Edward Wright Building: Room G51
Tel:  +44 1224 273350
Fax: +44 1224 273372



> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Leo Bakker
> Sent: Thursday, July 10, 2008 8:22 AM
> To: [hidden email]
> Subject: daily number of patients
>
> Hi Everyone,
>
> I hope someone can help me with this one.
> I have a lot of patients with an admission and dischargedate (dd-mm-yyyy).
> What I want to calculate is how many patients there were on each day of
> the year (occupied beds), and how many got in and out each day (turn
over).

> I know it can be done in SPSS, but i can't see how.
>
> Thanks,
> Leo
>
> =====================
> 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


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
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: daily number of patients

Maguin, Eugene
In reply to this post by Leo Bakker
Leo,

>>I have a lot of patients with an admission and dischargedate (dd-mm-yyyy).
What I want to calculate is how many patients there were on each day of
the year (occupied beds), and how many got in and out each day (turn over).

I won't claim that my method is the quickest or most elegant. It seems like
it should work.

Basically, my idea is to setup a vector whose elements correspond to the
julian days of the year(s). Then, taking each patient in turn, examine their
admission and discharge dates and make the corresponding vector element as
1=present for each day between and including the admission and discharge
dates. Then use aggregate (with a trick) to sum across cases. Those totals
are the daily census. Turnover is the difference between adjacent days.

I'd do a frequencies on the admit date and the discharge date to determine
the range. Figure out the number of days and set up your vector. There will
some work required to go between the vector index and the date while keeping
track of the year, if your dataset spans multiple years. But I don't think
that will be too hard.

The aggregation trick is to create a new variable, fix its value to a
constant and use that variable as the break variable.

Does this help enough?

Gene Maguin

=====================
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: daily number of patients

Richard Ristow
In reply to this post by Leo Bakker
At 03:22 AM 7/10/2008, Leo Bakker wrote:

>I hope someone can help me with this one.
>I have a lot of patients with an admission and dischargedate
>(dd-mm-yyyy). What I want to calculate is how many patients there
>were on each day of the year (occupied beds), and how many got in
>and out each day (turn over).

This is essentially a 'long'-data version of the solution Gene
suggested. It requires that UNROLL be a name or file handle for a
scratch file on disk (not a dataset). It assumes variables PatientID,
AdmitDate DischDate. It won't have any record for any day with
patient census 0. And it's not tested.

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 = AdmitDate to DischDate 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.

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).
END LOOP.
   AdmitDay 'Flag: This is the

=====================
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: daily number of patients

Richard Ristow
At 03:07 AM 7/11/2008, Leo Bakker wrote, off-list:

>The syntax you provided is not working and I'm not good enough in
>loops to see what is wrong.
>
>I made, as said,  the following variables in my file.
>
>AdmitDate       Date    11
>DischDate       Date    11
>Today           Date    11
>AdmitToday      Numeric
>DischToday      Numeric
>PatientID       Numeric
>
>When I start the LOOP you made:
>LOOP  Today =  AdmitDate to DischDate BY TIME.DAYS(1).
>[...]
>END LOOP.
>I get a list of errors, as if these variables don't exist, [e.g.]
>
>LOOP  Today =  AdmitDate to DischDate BY TIME.DAYS(1).
>
>>Error # 4285 in column 16.  Text: AdmitDate
>>Incorrect variable name: either the name is more than 64
>>characters, or it is not defined by a previous command.
>>This command not executed.
[etc.]

Well, it's not subtle: You have the right variables in your file, but
that file isn't active (isn't the active dataset) when you run the
code. How that happened, you don't give enough information to say.

Anyway, here's a test run (WRR: there is a separate code file). It's
the code I previously posted, except for
. Dropping an erroneous period from the end of the first line of the
NUMERIC statement;
. Dropping an END LOOP statement that I'd somehow left in after the AGGREGATE;
. Adding some LIST statements.

Test data:
|-----------------------------|---------------------------|
|Output Created               |23-JUL-2008 20:18:52       |
|-----------------------------|---------------------------|
PatientID   AdmitDate   DischDate

    101    09-MAR-2008 14-MAR-2008
    102    03-MAR-2008 15-MAR-2008
    103    07-MAR-2008 08-MAR-2008


Number of cases read:  3    Number of cases listed:  3


*  ................................................................. .
*  .................   Code to be posted       ..................... .

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 = AdmitDate to DischDate 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  /*-*/.

List
|-----------------------------|---------------------------|
|Output Created               |23-JUL-2008 20:18:55       |
|-----------------------------|---------------------------|
C:\Documents and Settings\Richard\My Documents\Temporary\SPSS
   \2008-07-11 Bakker - daily number of patients - UNROLL.SAV

PatientID       Today AdmitToday DischToday

    101    09-MAR-2008      1          0
    101    10-MAR-2008      0          0
    101    11-MAR-2008      0          0
    101    12-MAR-2008      0          0
    101    13-MAR-2008      0          0
    101    14-MAR-2008      0          1
    102    03-MAR-2008      1          0
    102    04-MAR-2008      0          0
    102    05-MAR-2008      0          0
    102    06-MAR-2008      0          0
    102    07-MAR-2008      0          0
    102    08-MAR-2008      0          0
    102    09-MAR-2008      0          0
    102    10-MAR-2008      0          0
    102    11-MAR-2008      0          0
    102    12-MAR-2008      0          0
    102    13-MAR-2008      0          0
    102    14-MAR-2008      0          0
    102    15-MAR-2008      0          1
    103    07-MAR-2008      1          0
    103    08-MAR-2008      0          1

Number of cases read:  21    Number of cases listed:  21


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).

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |23-JUL-2008 20:18:56       |
|-----------------------------|---------------------------|
       Today Patients Admits Discharges

03-MAR-2008      1       1        0
04-MAR-2008      1       0        0
05-MAR-2008      1       0        0
06-MAR-2008      1       0        0
07-MAR-2008      2       1        0
08-MAR-2008      2       0        1
09-MAR-2008      2       1        0
10-MAR-2008      2       0        0
11-MAR-2008      2       0        0
12-MAR-2008      2       0        0
13-MAR-2008      2       0        0
14-MAR-2008      2       0        1
15-MAR-2008      1       0        1

Number of cases read:  13    Number of cases listed:  13
=============================
APPENDIX: Test data, and code
=============================
*  ................................................................. .
*  .................   File handle             ..................... .

FILE HANDLE UNROLL
  /NAME='C:\Documents and Settings\Richard\My Documents'              +
          '\Temporary\SPSS\'                                          +
        '2008-07-11 Bakker - daily number of patients'                +
        ' - '                                                         +
        'UNROLL.SAV'.

*  .................   Test data               ..................... .

SET RNG = MT       /* 'Mersenne twister' random number generator  */ .
SET MTINDEX = 1845 /*  Providence, RI telephone book              */ .

INPUT PROGRAM.
.  NUMERIC  PatientID           (N3)
             AdmitDate DischDate (DATE11).
.  LEAVE    PatientID.
*  Three patients; admission dates uniform over the 10 days from     .
*  01 Mar 2008, length of stay exponential with mean 5 days.         .
.  LOOP     PatientID   = 101 TO 103.
.     COMPUTE #StrtDay  = TRUNC(RV.UNIFORM(0,10)).
.     COMPUTE AdmitDate = DATE.MDY(03,01,2008) + TIME.DAYS(#StrtDay).
.     COMPUTE #LOS      = TRUNC(RV.EXP(0.2))   + 1.
.     COMPUTE DischDate = AdmitDate            + TIME.DAYS(#LOS).
.     END CASE.
.  END LOOP.
END FILE.
END INPUT PROGRAM.

LIST.

*  ................................................................. .
*  .................   Code to be posted       ..................... .

*  The following was initially as the exact code from my posting     .
*     Date:         Thu, 10 Jul 2008 17:13:06 -0400                  .
*     From:         Richard Ristow <[hidden email]>         .
*     Subject:      Re: daily number of patients                     .
*     To:           [hidden email]                         .
*                                                                    .
*  What's below is debugged as needed, without specific change notes .

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 = AdmitDate to DischDate 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).

LIST.

=====================
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