06-10-2016 03:44 AM
I have two questions (i'm using SAS 9.4)
First, I am trying to construct episodes of care from 2 or more hospital separations. Basically if the patient is discharged from one facility then admitted to another facility within less than 2 days, we will consider this one, continuous episode of care (code below).
My problem is that I can see which separations should be grouped together when I review the data visually but I cannot think of the coding that will create a unique number or something to group them together. I think I will need to create a code and run several times for patients who have multiple separations that results in multiple episodes of care.
Second, I would then like to collapse all data fields from the 2 or more separations that make up the episode of care into one single line so I can analyse (data fields not shown in screen shot, but things like comorbidities and medications)
My coding for step 1:
Ref_date = LAG(discharge_date); * Retrieve the value of the previous discharge date;
Format Ref_Date DDMMYY10.;
Label Ref_Date = “Reference Date”;
Gap = admission_date - Ref_Date; * Calculate the gap between the current admission date and the previous discharge date;
if First.newid then do; * Reset the values of the following fields in case of a new patient ID;
Ref_date = .;
Gap = 999999;
Tag = .;
Readmissions = .;
If 0 <= Gap <= 1 then Tag = 1; * Identify a readmission and assign value 1 to Tag;
Readmissions + Tag; * Calculate cumulative readmissions;
if readmissions=. then readmissions=0;
if tag=. then tag=0;
if first.newID=last.newID and gap=999999
and tag=0 then admit_once=1; * Identify patients with only single separation;
See example data output in the attached file. You can see the patient 4 (newID) has four hospital separations. The last two should be considered as one episode of care as the patient comes into one hospital and then is discharged and readmitted to a different hospital (Ie: a transfer).
Thanks for you time in advance!
06-10-2016 11:01 AM
If you would like to have anyone test code then please provide example data in the form of a datastep that we can execute. No one is going to attempt to copy text from and image to create a dataset. Also we might assign other characterstics to your values that are incompatible with your actual data making the tested code moot.
If I understand your first step then instead of increment readmissions within the time frame you may be better of with a variable that increments only when it is outside of the time frame. That would be the "episode of care" count.
I am not at all clear about your second requirement but it sounds like you might attempt to put all of the variables from multiple visits into a single record. In a very large number of applications this approach leads to so many complications (and variables) that the project becomes very difficult to manage.
06-15-2016 08:51 AM
Thank you for your reply. I am new to SAS and posting here, so I did not realise about the data. Thanks for letting me know.
Please find some example data below.
In response to your question, yes - I may be better off with a variable that increments only when it is outside of the time frame. Essentially, I would like to cluster particular separations together (when less than 2 days between separations) as they should make up the same episode and then randomly select one episode of care for each patient for inclusion in my study.
In response to the second part, the variables that I would like to collapse together from hospital separations are few, and are binary variables, coded from original data (ie: patient has had an MI, yes or no, patient take aspirin, yes or no).
Thanks for your help in advance.
data episodes; input site $1-5 separation_mode_short_desc $6-52 newid 53-54 n 54-55 admission_date DDMMYY10. discharge_date DDMMYY10.; format admission_date DDMMYY10. discharge_date DDMMYY10.; cards; SiteB Separation to private residence/accommodation 1 1 30/8/2012 5/9/2012 SiteB Separation to private residence/accommodation 2 1 24/2/2014 26/2/2014 SiteM Separation to private residence/accommodation 3 1 13/5/2015 14/5/2015 SiteB Transfer to other acute facility 4 1 3/8/2012 3/8/2012 SiteA Separation to private residence/accommodation 4 2 7/8/2012 17/8/2012 SiteM Transfer to other acute facility 4 3 17/1/2014 23/1/2014 SiteB Death 4 4 23/1/2014 4/2/2014 SiteB Transfer to other acute facility 5 1 5/8/2014 8/8/2014 SiteB Transfer to aged care residential facility 6 1 7/7/2014 15/7/2014 SiteB Death 6 2 26/9/2015 3/10/2015 SiteB Transfer to other acute facility 7 1 10/5/2011 26/5/2011 SiteP Separation to private residence/accommodation 7 2 26/5/2011 17/6/2011 SiteM Separation to private residence/accommodation 8 1 16/5/2015 23/5/2015 SiteB Separation to private residence/accommodation 9 1 14/1/2011 14/1/2011 SiteB Separation to private residence/accommodation 9 2 15/4/2011 15/4/2011 ; run;