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 (February 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 3 Feb 2011 03:48:37 -0500
Reply-To:     "Kirby, Ted" <ted.kirby@LEWIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Kirby, Ted" <ted.kirby@LEWIN.COM>
Subject:      Re: Calculating a 30-day window from changing dates
Content-Type: text/plain; charset="iso-8859-1"

Max, If Tom was in hospital A for one year, then there can be no other hospital stays within that year. A person cannot be in two hospitals at the same time.

________________________________

From: SAS(r) Discussion on behalf of bbser 2009 Sent: Wed 2/2/2011 10:40 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Calculating a 30-day window from changing dates

OK. It's clear on that point now. But here is another issue. Think about an ultra-most case where Tom was with hospital A for like one year or even 10 years. Then any other treatments for Tom from other hospitals which felt in the admission and discharge period with hospital A would not be counted as index admissions. This sounds not reasonable. Using admit dates as "anchors" makes much sense to me.

Anyway, if you insist on discharge dates, I guess it is not hard to modify my original code for this purpose.

Max

From: Emily Sim [mailto:emilyssim@gmail.com] Sent: February-02-11 9:42 PM To: bbser 2009 Cc: SAS-L@listserv.uga.edu Subject: Re: Calculating a 30-day window from changing dates

Sorry, that surely is confusing. Each observation represents a hospital stay, so each observation has an admit date and a discharge date. An observation is considered an "index admit" if the admit date for that observation is greater than 30 days from the discharge date of the previous index admit. Does that clear it up?

Thanks,

Emily

On Wed, Feb 2, 2011 at 7:27 PM, bbser 2009 <bbser2009@gmail.com> wrote:

Emily

In your original post, you did mention using admit date instead of discharge date to be candidates of index dates. I thought it made sense that way.

Because of your last email, I was confused. Did you mean the first admit date after 30 days of "index discharge date" would be another index admit date? Thanks.

Max

From: Emily Sim [mailto:emilyssim@gmail.com] Sent: February-02-11 8:54 PM To: bbser 2009 Cc: SAS-L@listserv.uga.edu Subject: Re: [SAS-L] Calculating a 30-day window from changing dates

Thanks Max.

One note of clarification, the 30 day window is from the discharge date, not the admit date. So I think I would need to amend your code to be index_admit = disch_date after the first do statement. But is seems to make sense after that.

Does your code work for index admits after the second one? Wouldn't this just give me the first index admit and the second one, but not any after that?

Thanks so much,

Emily

On Wed, Feb 2, 2011 at 6:13 PM, bbser 2009 <bbser2009@gmail.com> wrote:

Given an index admission, the first admission coming right after 30 days of the index admission would be another index admission. If this understanding is right, please try the code below.

Max

==== code after your first data step ====

proc sort data=hypo; by ID ADMIT_DATE; run;

data index (drop=index_admit); set hypo; by id admit_date; retain index_admit; if first.id <http://first.id/> then do; index_admit=admit_date; output; end; else if admit_date-index_admit >=30 then do; index_admit=admit_date; output; end; run;

proc print; run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Emily Sim Sent: February-02-11 6:58 PM To: SAS-L@LISTSERV.UGA.EDU Subject: [SAS-L] Calculating a 30-day window from changing dates

My data consists of hospital admissions. Each observation is one hospital admission for a patient (includes patient ID, Hospital Name, Admit Date, Discharge Date, and Discharge Status)

I'm trying to determine which hospital admissions for each patient are "index admissions." There have to be at least 30 days between index admissions. The first admission for any patient is an index admission and then you count 30 days before another admission can be coded as an index admission. Any other admissions for a patient are either readmissions (if it is the first admission occurring within 30 days of an index admission) or "not a readmission" (if it is another admit after a readmission but before another index admission).

PROBLEM: How can I determine which hospital admissions are "index admissions" in a streamlined way? I have written code that will do it if the patient has up to 4 hospital admissions, but it is cumbersome and will become too unwieldy for higher numbers of admissions (the highest number of admissions for one patient in my real dataset is 46).

Thanks for any help (my data and code follow below),

-Emily

My real dataset has over 350,000 obs. I've created a miniature version to learn on.

Each obs is a hospital admission. Variables are ID (patient ID), HOSP_NAME (hospital name), ADMIT_DATE (date of admission), DISCH_DATE (date of discharge), DISCH_STATUS (discharge status of patient).

Here is the code I have written so far. First I read in the dataset, then I get rid of hospital transfers (DISCH_STATUS = 02), then I start identifying index admissions and readmissions. I use IF THEN statements to identify index admissions and I'll be the first to admit it isn't elegant!

data hypo; input ID $ 1 HOSP_NAME $ 2-11 @12 ADMIT_DATE MMDDYY10. @22 DISCH_DATE MMDDYY10. DISCH_STATUS $ 32-33 ; format ADMIT_DATE DISCH_DATE mmddyy10.; cards; 1StRoseSan 05/23/200906/24/200909 1StRoseSie 05/10/200905/23/200902 1NorthVista05/10/200905/10/200902 1NorthVista06/28/200907/01/200909 2Sunrise 01/05/200901/07/200902 2NorthVista01/07/200901/09/200909 2Sunrise 01/15/200901/17/200909 2Sunrise 01/22/200901/24/200909 2Sunrise 02/05/200902/09/200909 2Sunrise 06/01/200906/10/200909 3NorthVista06/11/200906/11/200902 3NorthVista06/11/200906/18/200909 4Sunrise 09/25/200909/28/200909 4Sunrise 09/30/200909/30/200920 ; run;

proc sort data=hypo; by ID ADMIT_DATE DISCH_DATE; run;

/*This next section recodes hospital transfers as only one visit - so if a patient is transfered twice, it still appears as one hospital admit instead of 3*/

data hypo2; set hypo; PREV_DISCH_STATUS = lag1(DISCH_STATUS); PREV_ADMIT_DATE = lag1(ADMIT_DATE); format PREV_ADMIT_DATE mmddyy10.; run;

/*deleting middle transfers - when a patient was transfered more than once*/ data hypo3; set hypo2; if DISCH_STATUS = '02' and PREV_DISCH_STATUS = '02' then delete; run;

data hypo4; set hypo3; if PREV_DISCH_STATUS = '02' then ADMIT_DATE = PREV_ADMIT_DATE; run;

/*deleting the initial admit before the transfer - the transferred admit now has the admit date from the initial admit*/ data hypo5; set hypo4; if DISCH_STATUS = '02' then delete; if PREV_DISCH_STATUS = '02' then COLLAPSED = 'Y'; else COLLAPSED = 'N';

/*HERE IS WHERE I START TO COUNT INDEX ADMITS (AND READMISSIONS)*/

/*a patient can only have one index admit within each 30-day period. The 30-day count starts from each index admit*/

/*first counting the number of admits for each patient - COUNT = 1 is the first admit, COUNT = 2 is the second, etc.*/

data hypo6; set hypo5; COUNT + 1; by ID; if first.ID then COUNT=1; run;

data hypo9; set hypo6; DAYS_LAG1 = ADMIT_DATE - lag1(DISCH_DATE); DAYS_LAG2 = ADMIT_DATE - lag2(DISCH_DATE); DAYS_LAG3 = ADMIT_DATE - lag3(DISCH_DATE); DAYS_LAG4 = ADMIT_DATE - lag4(DISCH_DATE); run;

data hypo10; set hypo9; if COUNT = 1 then DAYS_FROM_INDEX = .; if COUNT = 2 then DAYS_FROM_INDEX = DAYS_LAG1; if COUNT = 3 then DAYS_FROM_INDEX = DAYS_LAG2; if COUNT = 4 then DAYS_FROM_INDEX = DAYS_LAG3; if COUNT = 5 then DAYS_FROM_INDEX = DAYS_LAG4; run;

/*CODING INDEX ADMITS FOR COUNT = 2 (PATIENTS WITH 2 ADMISSIONS)*/

data hypo11; set hypo10; if COUNT = 1 then INDEX_ADMIT = 'Y'; if COUNT = 2 and DAYS_FROM_INDEX >30 then INDEX_ADMIT = 'Y'; if COUNT = 2 and DAYS_FROM_INDEX <= 30 then READMISSION = 'Y'; run;

/*Now dealing with COUNT = 3 (PATIENTS WITH 3 ADMISSIONS)*/

data hypo12; set hypo11; DAYS_FROM_SECOND = ADMIT_DATE - lag1(DISCH_DATE); THIRD_PREV_INDEX = lag1(INDEX_ADMIT); THIRD_PREV_READMISSION = lag1(READMISSION); if COUNT = 3 and THIRD_PREV_INDEX = 'Y' and DAYS_FROM_SECOND >30 then INDEX_ADMIT = 'Y'; if COUNT = 3 and THIRD_PREV_INDEX = 'Y' and DAYS_FROM_SECOND <=30 then READMISSION = 'Y'; if COUNT = 3 and THIRD_PREV_READMISSION = 'Y' and DAYS_FROM_INDEX >30 then INDEX_ADMIT = 'Y'; if COUNT = 3 and THIRD_PREV_READMISSION = 'Y' and DAYS_FROM_INDEX <=30 then READMISSION = 'N'; run;

/*Now dealing with COUNT = 4 (PATIENTS WITH 4 ADMISSIONS)*/

data hypo13; set hypo12; DAYS_FROM_THIRD = ADMIT_DATE - lag1(DISCH_DATE); DAYS_FROM_SECOND = ADMIT_DATE - lag2(DISCH_DATE); FOURTH_PREV_INDEX = lag1(INDEX_ADMIT); FOURTH_PREV_READMISSION = lag1(READMISSION); FOURTH_TWO_PREV_INDEX = lag2(INDEX_ADMIT); FOURTH_TWO_PREV_READMISSION = lag2(READMISSION); if COUNT = 4 and FOURTH_TWO_PREV_INDEX = 'Y' and FOURTH_PREV_INDEX = 'Y' and DAYS_FROM_THIRD >30 then INDEX_ADMIT = 'Y'; if COUNT = 4 and FOURTH_TWO_PREV_INDEX = 'Y' and FOURTH_PREV_INDEX = 'Y' and DAYS_FROM_THIRD <=30 then READMISSION = 'Y'; if COUNT = 4 and FOURTH_TWO_PREV_INDEX = 'Y' and FOURTH_PREV_READMISSION = 'Y' and DAYS_FROM_SECOND >30 then INDEX_ADMIT = 'Y'; if COUNT = 4 and FOURTH_TWO_PREV_INDEX = 'Y' and FOURTH_PREV_READMISSION = 'Y' and DAYS_FROM_SECOND <=30 then READMISSION = 'N'; if COUNT = 4 and FOURTH_TWO_PREV_READMISSION = 'Y' and FOURTH_PREV_READMISSION = 'N' and DAYS_FROM_INDEX <30 then READMISSION = 'N'; if COUNT = 4 and FOURTH_TWO_PREV_READMISSION = 'Y' and FOURTH_PREV_READMISSION = 'N' and DAYS_FROM_INDEX >=30 then INDEX_ADMIT = 'Y'; if COUNT = 4 and FOURTH_TWO_PREV_READMISSION = 'Y' and FOURTH_PREV_INDEX = 'Y' and DAYS_FROM_THIRD >30 then INDEX_ADMIT = 'Y'; if COUNT = 4 and FOURTH_TWO_PREV_READMISSION = 'Y' and FOURTH_PREV_INDEX = 'Y' and DAYS_FROM_THIRD <=30 then READMISSION = 'Y'; run;

************* IMPORTANT - PLEASE READ ********************

This e-mail, including attachments, may include confidential and/or proprietary information,

and may be used only by the person or entity to which it is addressed. If the reader of this

e-mail is not the intended recipient or his or her authorized agent, the reader is hereby

notified that any dissemination, distribution or copying of this e-mail is prohibited. If you

have received this e-mail in error, please notify the sender by replying to this message

and delete this e-mail immediately.


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