Hello, I'm a novice SAS user (SAS 9.4) and I'm working with a healthcare dataset where I need to count the number of observations that were discharged and admitted on the same day at different places of service. Example, if ID 1 was seen at the ED on 01/01/2020 and was discharged on 01/02/2020 and Inpatient admission on 01/02/2020 then the new variable would count that as 1 service but if ID 1 was seen at the ED on 01/10/2020 and discharged on 01/10/2020 and Inpatient was admitted on 01/31/2020 then the new variable wouldn't count that. How would I create a variable that would count that? data SC.test;
input id $ admitdate:mmddyy10. dischargedate:mmddyy10. place $2. ;
format ADMITdate MMDDYY10. DISCHARGEdate MMDDYY10.;
datalines;
1 09/10/2020 09/10/2020 ED
1 09/10/2020 09/11/2020 IN
2 10/10/2020 10/12/2020 IN
3 04/03/2020 04/03/2020 ED
3 05/03/2020 05/03/2020 ED
3 05/29/2020 06/03/2020 IN
4 10/09/2020 10/10/2020 ED
4 10/10/2020 10/12/2020 IN
4 11/03/2020 11/03/2020 ED
4 12/29/2020 12/31/2020 IN
;
run; My expected output would be something like this: ID ADMITDATE DISCHARGEDATE PLACE NEWVAR 1 9/10/2020 9/10/2020 ED 1 1 9/10/2020 9/11/2020 IN 1 2 10/10/2020 10/12/2020 IN . 3 4/3/2020 4/3/2020 ED . 3 5/3/2020 5/3/2020 ED . 3 5/29/2020 6/3/2020 IN . 4 10/9/2020 10/10/2020 ED 1 4 10/10/2020 10/12/2020 IN 1 4 11/3/2020 11/3/2020 ED . 4 12/29/2020 12/31/2020 IN . I would really appreciate any insight. Thank you! Amanda
... View more