Admissions data (similar to last question)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Admissions data (similar to last question)

So I asked a question a few days ago and ended up figuring it out. Now I have to do more with similar data. I have a dataset with variables:

ID = patient id
FACILITY = facility id
Admission= date patient was admitted to hospital
Admission_Number= admission number for patient in that year
Days_Since_Last_Adm = days since the patient was last admitted to the hospital
CumulativeDaysSinceAdm = cumulative days since last admitted to the hospital

Ex Data:

IDFACILITYAdmissionadmission_numberDAYS_SINCE_LAST_ADMCumulativeDaysSinceAdm
1242/14/2012100
1243/3/201221818
2132/1/2012100
2135/11/20122100100
2135/21/2012310110
2136/13/2012423133
2136/25/2012512145
2137/13/2012618163
2137/20/201277170
2138/6/2012817187
2138/22/2012916203
21310/8/20121047250
21310/18/20121110260


I want to determine index admissions. In this case the index admissions are the first admission and any admission that occurs over 30 days after the previous index admission - If an admission appears that happens over 30 days from the last index admission that admission is labeled as an index admission and then all following admissions are compared to that latest index admission. For example, for patient id 2 the first index admission is admission 1. Admission 2 happens over 30 days after admission 1 so that is also an index admission. Admission 3 occurs ten days after 2 so its NOT and index admission. Admission 4 occurs 33 days after admission 2 (the most recent index admission) so admission 4 would be labeled an index admission. Admissions 5 and 6 do NOT happen > 30 days after admission 4 (the latest index admission) so they are NOT index admission, etc. etc. Does anyone have any ideas how to do this? Anything I have attempted so far has not worked. I have only been able to compare surrounding admissions so far but not admission such as 1 and 4 or 2 and 6. Any ideas or help would be much appreciated.


Accepted Solutions
Solution
‎01-03-2013 03:01 PM
Frequent Contributor
Posts: 81

Re: Admissions data (similar to last question)

Posted in reply to michlewski

Try below code. Variable INDEX identifies your index admissions.

data one;

input ID FACILITY Admission mmddyy10. admission_number DAYS_SINCE_LAST_ADM CumulativeDaysSinceAdm;

format admission date9.;

datalines;

1 24 2/14/2012  1 0 0

1 24 3/3/2012   2 18 18

2 13 2/1/2012   1 0 0

2 13 5/11/2012  2 100 100

2 13 5/21/2012  3 10 110

2 13 6/13/2012  4 23 133

2 13 6/25/2012  5 12 145

2 13 7/13/2012  6 18 163

2 13 7/20/2012  7 7 170

2 13 8/6/2012   8 17 187

2 13 8/22/2012  9 16 203

2 13 10/8/2012  10 47 250

2 13 10/18/2012 11 10 260

;

run;

proc sort data=one;  by id admission;  run;

data two;

  set one;

  by id admission;

  retain fdate;

  if first.id then do; index='Y'; fdate=admission; end;

  if admission-fdate > 30 then do; index='Y'; fdate=admission; end;

  format fdate date9.;

run;

View solution in original post


All Replies
Solution
‎01-03-2013 03:01 PM
Frequent Contributor
Posts: 81

Re: Admissions data (similar to last question)

Posted in reply to michlewski

Try below code. Variable INDEX identifies your index admissions.

data one;

input ID FACILITY Admission mmddyy10. admission_number DAYS_SINCE_LAST_ADM CumulativeDaysSinceAdm;

format admission date9.;

datalines;

1 24 2/14/2012  1 0 0

1 24 3/3/2012   2 18 18

2 13 2/1/2012   1 0 0

2 13 5/11/2012  2 100 100

2 13 5/21/2012  3 10 110

2 13 6/13/2012  4 23 133

2 13 6/25/2012  5 12 145

2 13 7/13/2012  6 18 163

2 13 7/20/2012  7 7 170

2 13 8/6/2012   8 17 187

2 13 8/22/2012  9 16 203

2 13 10/8/2012  10 47 250

2 13 10/18/2012 11 10 260

;

run;

proc sort data=one;  by id admission;  run;

data two;

  set one;

  by id admission;

  retain fdate;

  if first.id then do; index='Y'; fdate=admission; end;

  if admission-fdate > 30 then do; index='Y'; fdate=admission; end;

  format fdate date9.;

run;

Occasional Contributor
Posts: 16

Re: Admissions data (similar to last question)


This worked! Thank you so much!

Super User
Posts: 19,770

Re: Admissions data (similar to last question)

Posted in reply to michlewski

I think this will give you what you want;

data want;

set have;

by id;

retain index index_date ;

if first.id then index=0;

if DAYS_SINCE_LAST_ADM>30 or first.id then do;

      index=index+1;

     index_date=admission;

end;

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 208 views
  • 0 likes
  • 3 in conversation