Break down number of days in hospital by calendar month
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | *(Q) I would like to determine the number of bed-days used per month with 2 dates-intake & exit. I would like the calculation by month. * No intake end month1 month2 month3 etc... * 1 1/5/01 2/5/01 25 5 0 * 2 2/7/01 3/7/01 0 21 7 * 3 4/3/01 5/25/01 ? ? ? *(A) Posted to SPSSX-L by rlevesque@videotron.ca on 2001/11/20. * Note: The following syntax is not completely general. * It assumes that all dates are in the same calendar year. DATA LIST LIST /id(F8) datein(ADATE) dateout(ADATE). BEGIN DATA 1 1/5/01 2/5/01 2 2/7/01 3/7/01 3 4/3/01 5/25/01 4 2/1/01 4/4/01 5 1/31/01 4/1/01 6 7/1/01 9/29/01 7 9/10/01 12/30/01 END DATA. LIST. VECTOR month(12F8). COMPUTE #oneday=24*60*60. LOOP mth=1 TO 12. COMPUTE beg1=MAX(datein , DATE.DMY(1,mth,XDATE.YEAR(datein))). COMPUTE end1=MIN(dateout + #oneday, DATE.DMY(1,mth+1,XDATE.YEAR(datein))). COMPUTE month(mth)=max(0, CTIME.DAYS(end1 - beg1)). END LOOP. EXECUTE. |
Related pages
...
Navigate from here