Sorry, my explanation was not clear. I created a new dataline . data have; input IDl ID2 ID3 ID4 ID5 FROM_DT: date9. TO_DT:date9. Amount; datalines; 10 12 100 1 4 31DEC2019 31DEC2021 100.00 10 12 100 1 4 31DEC2012 31DEC2019 100.00 10 12 101 4 4 31DEC2019 31DEC2021 200.00 10 12 101 4 4 31DEC2012 31DEC2019 200.00 10 12 103 6 4 31DEC2012 31DEC2019 300.00 10 12 103 6 4 31DEC2019 31DEC2021 300.00 10 12 104 7 4 31DEC2012 31DEC2019 400.00 10 12 104 7 4 31DEC2019 31DEC2021 400.00 11 13 105 3 6 01JUL2019 31DEC4747 500.00 11 13 105 3 6 01OCT2019 31DEC4747 500.00 11 14 106 4 4 010CT2019 31DEC4747 600.00 11 14 106 4 4 01JUL2019 31DEC4747 700.00 ; Here Key fields are ID1, ID2, ID3,Id4,ID5. So for this combination: 1. if Amt were the same and no overlapping dates i.e. if I take the first two rows then take min(to_date) and max(from_date) 10 12 100 1 4 31DEC2019 31DEC2021 100.00 10 12 100 1 4 31DEC2012 31DEC2019 100.00 should become 10 12 100 1 4 31DEC2012 31DEC2021 100.00 2. if amt are same or different and if the dates are overlapping for ex: below rows 11 14 106 4 4 010CT2019 31DEC4747 600.00 11 14 106 4 4 01JUL2019 31DEC4747 700.00 I have to flag row 11 14 106 4 4 010CT2019 31DEC4747 600.00 as 1 and 11 14 106 4 4 01JUL2019 31DEC4747 700.00 as 0 as they are overlapping dates so I have to flag the row with latest to_date to 1. Please help me with this. Regards, Jay
... View more