Date: Fri, 18 Nov 2011 09:52:11 -0800
Reply-To: mlhoward@avalon.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary <mlhoward@AVALON.NET>
Subject: Re: aggregating claims into inpatient treatment episodes
Content-Type: text/plain; charset="UTF-8"
I can tell you a conceptual way to do this, though don't have time to work out the code.
For the period you have, create an array that has enough elements to have one position per day; this can be a numeric array in which you are going to put in a 1 if the person is in the hospital or not. So you have a data step that uses the facility hospital claims (hopefully that is what you have; physican claims would be harder), and then for each record, loop from the admission date to the discharge date and put a 1 in the corresponding element in the array. Do this for each patient, and output only once you reach the last record for that patient, then initialize the array back to 0 and start reading in claims for the next patient.
Then that resulting data set should give you what you need for admission discharge- you would have something like this
patientID day1, day2,
001 0000000000011111000000000011110000000011111
Then you can take this data set and the isolate the 1's, where the start of a 1 is the first day of admit, and the end of the string of 1's is the date of discharge.
-Mary
--- Lorna.Simon@UMASSMED.EDU wrote:
From: "Simon, Lorna" <Lorna.Simon@UMASSMED.EDU>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: aggregating claims into inpatient treatment episodes
Date: Fri, 18 Nov 2011 12:32:29 -0500
I am defining an episode as claims which have no more than 1 day between them, i.e. if from_date2-to_date1 is no more than 1 day. Does that make sense?
I'm working on a solution now that combines your sql code with my original code. I'll keep you posted on how that works. Thanks for all your help. I really appreciate it.
From: toby dunn [mailto:tobydunn@hotmail.com]
Sent: Friday, November 18, 2011 12:28 PM
To: Simon, Lorna; sas-l@listserv.uga.edu
Subject: RE: aggregating claims into inpatient treatment episodes
Lorna,
I mentioned that is what it did in the post. The reason is you have failed to give the rules by which you want to define as a Episode.
For instance here on one project we define an episode as admissions that are within ten days from the previous discharge date.
So inorder to get what you need you need ot define how you are defining a episode.
Toby Dunn
If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain.
"Any idiot can face a crisis-it's day to day living that wears you out"
~ Anton Chekhov
________________________________
From: Lorna.Simon@umassmed.edu
To: tobydunn@hotmail.com; SAS-L@LISTSERV.UGA.EDU
Date: Fri, 18 Nov 2011 12:22:04 -0500
Subject: RE: aggregating claims into inpatient treatment episodes
Unfortunately, Toby your elegant solution does not do what I want it to. One person can have many hospitalizations, so I can't just take the min and max of the dates - that only gives me one observation per person, with their 1st admission date and their last discharge date. Any other ideas anyone?
From: toby dunn [mailto:tobydunn@hotmail.com]
Sent: Friday, November 18, 2011 10:09 AM
To: Simon, Lorna; sas-l@listserv.uga.edu
Subject: RE: aggregating claims into inpatient treatment episodes
Since I didnt see anything about the number of days between date ranges what it looks like you want is simply the min and max dates.
Proc SQL ;
Create Table Need As
Select Distinct Project_ID , Min( From_Date ) As Adm_Date , Max( To_Date ) As Dis_Date
From Have
Group By Project_Id ;
Quit ;
Toby Dunn
If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain.
"Any idiot can face a crisis-it's day to day living that wears you out"
~ Anton Chekhov
> Date: Fri, 18 Nov 2011 10:03:24 -0500
> From: Lorna.Simon@UMASSMED.EDU
> Subject: aggregating claims into inpatient treatment episodes
> To: SAS-L@LISTSERV.UGA.EDU
>
> I have a claims dataset that I need to condense into 1 treatment episode - there can be many claims for each treatment episode (1 hospitalization). I found code in the archives which does this for most of the claims. However, for some hospitalizations, the claims are not consecutive - some of the hospitalizations may have claims which overlap.
>
> Here are the data I have:
> Obsnum project_id from_date to_date
> 1 1 1/1/2007 1/20/2007
> 2 2 6/30/2008 7/2/2008
> 3 2 7/3/2008 7/5/2008
> 4 3 9/9/2009 9/14/2009
> 5 3 9/10/2009 9/16/2009
>
> Data I want:
> project_id adm_date dis_date
> 1 1/1/2007 1/20/2007
> 2 6/30/2008 7/5/2008
> 3 9/9/2009 9/16/2009
>
> Here is my code:
>
> proc sort data=mhub92inpatientclaims; by project_id from_date to_date; run;
> data claims;
> set MHUB92inpatientclaims;;
> by project_id from_date;
> lagto = lag(to_date);
> lagfrom=lag(from_date);
> if first.project_id then do;
> lagto = .;
> lagfrom=.;
> stay = 1;
> end;
> if from_date-lagto ge 2 then stay + 1;
> lagstay=lag(stay);
> if from_date ge lagfrom and to_date le lagto then stay=lagstay;
> format lagto lagfrom from_date to_date mmddyy10.;
> run;
> data dig.mhub92inpdischargeclaims11_18_11;
> do until(last.stay);
> set claims;
> by project_id stay;
> if first.stay then adm_date = from_date;
> end;
>
> the code works for project_ids 1 and 2, but not for project_id 3. I am still getting 2 lines for project_id, one with a treatment episode from 9/9/2009-9/9/14 and one with a treatment episode from 9/10/2009-9/16/2009 . the highlighted code is what I added to the code I found on the web in the hope of solving this problem, but obviously it is not working.
>
> Any suggestions would be appreciated. Thanks.