Hi ,
I have the following data.I need to compare date1 with date2(with the existing one) and get the period in days .
subj date1 date2
1 03/02/2019
1 04/02/2019
1 05/02/2019
1 06/02/2019
1 07/02/2019
1 08/02/2019 08/02/2019
1 09/02/2019
1 11/02/2019
1 14/02/2019
1 18/02/2019
1 25/02/2019
1 03/03/2019
1 04/03/2019
1 06/03/2019
1 07/03/2019
1 08/03/2019
1 09/03/2019
1 10/03/2020 10/03/2020
1 11/03/2020
1 13/03/2020
1 15/03/2020
1 17/03/2020
I need as
subj date1 date2 days
1 03/02/2019 -5
1 04/02/2019 -4
1 05/02/2019 -3
1 06/02/2019 -2
1 07/02/2019 -1
1 08/02/2019 08/02/2019 0
1 09/02/2019 1
1 11/02/2019 3
1 14/02/2019 5
1 18/02/2019 7
1 03/03/2019 -7
1 04/03/2019 -6
1 06/03/2019 -4
1 07/03/2019 -3
1 08/03/2019 -2
1 09/03/2019 -1
1 10/03/2020 10/03/2020 0
1 11/03/2020 1
1 13/03/2020 3
1 15/03/2020 5
1 17/03/2020 7
Appreciate your help.Thanks
What is the logic which says use DATE2 = 08/02/2019 instead of DATE2 = 10/03/2019 on some rows, and use DATE2 = 10/03/2019 instead of DATE2 = 08/02/2019 on other rows??
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.