LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 28 Apr 2008 15:02:39 -0400
Reply-To:     Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:      Re: Length of stay by month
Comments: To: Richard Van Dorn <richard.vandorn@DUKE.EDU>
In-Reply-To:  A<200804281717.m3SGTHwW026036@malibu.cc.uga.edu>
Content-Type: text/plain; charset="utf-8"

Richard,

Here is one approach. It creates a format for the month numbers (1-88). The data you have with admit and discharge dates is used to create a data set with one observation for each day of the stay. Then, that data set is summarized with PROC SUMMARY at the ID and Month level - using the PRELOADFMT and COMPLETETYPES options to include all months for each ID.

Hope this helps.

* create data set with month and corresponding numbers ; data monfmt (drop=months i); retain months '01NOV1999'd fmtname '$monnum' ; do i = 1 to 88; start = put(months,monyy.); label = put(i,2.); months = intnx('month', months, 1); output; end; run;

* create format of month numbers ; proc format cntlin=monfmt; run;;

* print format for audit (optional); proc format library=work fmtlib; select $monnum; run;

* test data ; data have; id=1; admit='29JAN2003'd; discharge='30JAN2003'd; output; id=1; admit='12MAR2003'd; discharge='03APR2003'd; output; id=2; admit='01JAN2005'd; discharge='30JAN2005'd; output; run;

* create 1 obs per day for stay ; data need1 (keep=id month); set have; do i=admit to discharge; month = put(i,monyy.); output; end; run;

* summarize days/month per id and apply formatting ; proc summary data = need1 nway order=formatted completetypes; class id; class month / preloadfmt; format month $monnum.; output out = need2 (rename=(_freq_=los) drop=_type_); run;

proc print data = need2; run;

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Richard Van Dorn Sent: Monday, April 28, 2008 1:18 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Length of stay by month

Hello all,

I have a question about calculating length of stay (LOS) by month. I’ve searched the List’s Archives and haven’t found a solution that meets my needs; however, I apologize in advance if I’ve missed an already discussed solution. Currently, my data are currently structured as:

ID admit discharge 1 29JAN2003 30JAN2003 1 12MAR2003 03APR2003

From these data I would like to create a variable for LOS for each month (in these data there are a total of 88 months, which start on 01NOV1999 and end on 28FEB2007). For example, for the month of January 2003 subject ID 1 was in the hospital for 2 days that month (I am counting both the admit and discharge dates as separate days). However, for the month of March this person was in the hospital from the 12th through the end of the month (31st) for a total of 20 days; this particular visit, however, spanned 2 months so there are an additional 3 days for April.

Eventually, I would like for the data to look like this (in this example January 2003 is equal to the 39th month [of 88 total] in the data; month 40 is equal to February 2003, which had no hospitalization days; month 41 is equal to March 2003 and month 42 is equal to April 2003):

ID Month LOS 1 1 0 1 2 0 . . . . . . . . . 1 39 2 1 40 0 1 41 20 1 42 3 1 . . 1 . . 1 . . 1 88 0

Thank you for giving this some thought and I certainly appreciate any help you can provide!

Richard


Back to: Top of message | Previous page | Main SAS-L page