CONTINUATION...
1. If the discharge is followed by readmission or direct transfer to an acute inpatient care setting within 30-day follow-up period, count only the last discharge.
e.g.
ID ADMIT_DT DISCH_DT DAYS_DIFF
011 1/10/2018 1/13/2018 16 <<< "readmission within 30 days - only include last discharge"
011 1/29/2018 2/28/2018
022 2/13/2018 2/17/2018 55 <<< "readmission >30 days"
022 4/13/2018 4/25/2018
2. For member with same admission date, but different discharge dates; use the last discharge date.
e.g.
ID ADMIT_DT DISCH_DT
033 5/11/2018 5/12/2018
033 5/11/2018 5/17/2018
3. For member with same discharge date, but different admit date; use the first admit date.
e.g.
ID ADMIT_DT DISCH_DT
033 6/11/2018 6/17/2018
033 6/13/2018 6/17/2018
4. For member with the same 1st discharge date and next admit date, count the 1st admit date and next discharge date.
e.g.
ID ADMIT_DT DISCH_DT DAYS_DIFF
033 08/11/2018 08/17/2018 0
033 08/17/2018 08/23/2018
I would like to loop through the dataset by using RETAIN STATEMENT. See the attachment for my SAS codes. I'm still a newbie in SAS and trying to figure out on how to retain/remove rows based on the criteria. Any help would be greatly appreciated. Thank you!