BookmarkSubscribeRSS Feed
sri1
Obsidian | Level 7

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

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

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??

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 442 views
  • 0 likes
  • 2 in conversation