'Creating datasets based on overlapping dates

I have a dataset which has window start and end dates. For an account there could be multiple cases and each case has separate window start and end dates. I want to create two datasets, one where the cases have overlapping window start and end dates and the other which does not have overlapping cases.

dataset that I have

 input acct_num case window_start window_end ;
    DATALINES; 
    55203610 1  10JAN2020 23FEB2020
    55203610 2  17JAN2020 13MAR2020
    55203610 3  31DEC2019 17MAR2020
    55203612 1  22FEB2021 09JUN2021  
    55203612 2  27AUG2021 31DEC2021
    55203614 1  11FEB2018 21MAR2018
    55203614 2  14MAR2018 23JUL2018
    ;
    run;

Datasets that I want.

overlapping dataset 

    55203610 1  10JAN2020 23FEB2020
    55203610 2  17JAN2020 13MAR2020
    55203610 3  31DEC2019 17MAR2020
    55203614 1  11FEB2018 21MAR2018
    55203614 2  14MAR2018 23JUL2018

Non overlapping dataset

    55203612 1  22FEB2021 09JUN2021  
    55203612 2  27AUG2021 31DEC2021

SO if you see the overlapping datasets has accounts with cases the dates are overlapping.

Any help will be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source