I am fairly new to SAS and am working on a sorting exercise to improve my SAS skills, but I seem to keep getting stuck since this dataset has observations with different date ranges.
I was given generated admission and discharge data for patients who visited two different hospitals. The data is sorted on admission date and is contained in one dataset. My goal is to create two datasets from this large dataset. The first dataset should contain the patient ID's for those patients who went to hospital A prior to visiting hospital B. The second data set should contain the patient ID's for those patients who went to hospital B prior to visiting hospital A. A sample of the main dataset looks like this:
ID Hospital Admission_Date Discharge_Date
1 A 21AUG2018 24AUG2018
1 A 02OCT2019 07OCT2019
1 B 07OCT2019 17OCT2019
2 B 01AUG2020 13AUG2020
2 A 28SEP2020 30SEP2020
3 B 17MAY2019 18MAY2019
3 A 18MAY2019 21MAY2019
3 B 21MAY2019 31MAY2019
The two resulting datasets should only include the patient ID's. For instance, for the datasets where patients went from Hospital A to Hospital B we should have something like this:
ID
1
For the cases where patients went from Hospital B to Hospital A, we should have something like this:
ID
2
3
Any help on this would be greatly appreciated!