Question about grouping data and determining information from groups

Reply
Occasional Contributor
Posts: 16

Question about grouping data and determining information from groups

I have a dataset with variables as follows:

Patient_id = unique patient number

Facility_id = unique clinic number

TEMPORARY_ABSENCE_DATE = date of hospital admission

TEMPORARY_ABSENCE_END_DATE = date of hospital discharge

diagnosis_code = ICD-9 code for hospitalization

diagnosis_description = translation of ICD-9 code to text

hosp_days = number of days in the hospital

For each patient(at each specific clinic) I am trying to determine the number of readmissions within 30 days - In my first method I need to determine the admissions that occur within 30 days of prior discharge and have no following discharge. I also need to determine admissions that occurred within 30 days of prior admission and have another admission within 30 days. I can determine the number of days between each discharge and the number of admissions for each patient, but beyond that I am lost as to how to write a program that can determine if there are following admissions and if so how far in time those admissions took place (within 30 days or not). Hopefully this question makes sense, if not I can add more info. Although I do not have much more info to give...

Super User
Posts: 17,840

Re: Question about grouping data and determining information from groups

Here's an example of a solution that was posted a while ago, it should be fairly close to what you're looking for.

https://communities.sas.com/thread/7012

Occasional Contributor
Posts: 16

Re: Question about grouping data and determining information from groups

My main problem is determining if the patient has been admitted previously (within less than 30 days from the index date). The index date in this case is an admission from which we count readmissons within 30 days (first admission during the period or no prior admission within 30 days). So, I have created a variable with the days since last disharge but I am confused how to use that variable to determine the admissions that occur within 30 days of prior discharge and have no following discharge. For example lets say there is a person who has been admitted on 6/20/2008 -6/22/2008, 8/23/2008 - 8/25/2008, 9/1/2008- 9/3/2008, and 9/20/2008-9/27/2008. The first and second admissions in this case are index admissions. I want to assign the 4th observation a readmission only status because its an admission that occurs within 30 days of prior discharge and has no following admissions. The issue is how do determine that in SAS.

Super User
Posts: 17,840

Re: Question about grouping data and determining information from groups

I don't see the problem, once you've created the lag you can use a second datastep to actually determine what's an 'index' visit. 

It will be one that isn't classified as a readmission and/or your first visit.

You can use first.facility_id assuming you're sorting and classifying according to patient/facility.

Give it a start and post the code you have if you need more help.

Occasional Contributor
Posts: 16

Re: Question about grouping data and determining information from groups

How do I say that someone's third (or fourth or fifth, etc) admission is one that should be flagged but not their others? Like in the example above if there were a fifth admission over 30 days away from the last I'd still want to flag the fourth admission.

This is what I have so far:

data mergecounts;

set o.hosp1;

by patient_id;

patientid_center = catt( of patient_id facility_id);

run;

proc sort data = mergecounts; by patientid_center; run;


data firstlast; set mergecounts;

by patientid_center;

first = first.patientid_center;

last = last.patientid_center;

if first.patientid_center then count = 0;

count+1;

/*1A */

lagdate = lag(TEMPORARY_ABSENCE_END_DATE);

if first.patientid_center ne 1 then DAYS_SINCE_LAST_DISCHARGE =  TEMPORARY_ABSENCE_DATE - laggeddate ;

if DAYS_SINCE_LAST_DISCHARGE > 30 or first = 1 then index = 1;

format laggeddate mmddyy10. admit2 mmddyy10.;
run;

Super User
Posts: 17,840

Re: Question about grouping data and determining information from groups

The code looks fine to me, but I'm assuming it doesn't work somewhere?

Can you post an example of the situation where it doesn't work, where you're not capturing your index=1 basically.

Occasional Contributor
Posts: 16

Re: Question about grouping data and determining information from groups

It works but doesnt answer my question, I need a second variable labeling the less than 30 day readmissions that occur without other admissions following them and I cannot figure out how to do that part.

PROC Star
Posts: 7,363

Re: Question about grouping data and determining information from groups

: It will be easier to respond if you post some example data along with the output file you want from that example data.

Super User
Posts: 17,840

Re: Question about grouping data and determining information from groups

You can create a readmission variable using the lagged duration, this will show which visits are readmissions.

i.e. readmission= (DAYS_SINCE_LAST_DISCHARGE <= 30);



I'm not sure what you mean by ' less than 30 day readmissions that occur without other admissions following them' so I can't comment on that but with the index and readmission I'm sure its possible.

Occasional Contributor
Posts: 16

Re: Question about grouping data and determining information from groups

Thanks everybody, the answer has been sorted out!

Ask a Question
Discussion stats
  • 9 replies
  • 395 views
  • 0 likes
  • 3 in conversation