BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mahossain
Calcite | Level 5

i.e first # of days (difference)  will be missing and the 2nd will be difference of Jan 22, 2020-Jan 01, 2020 and so on by ID
ID       Date                   # of days (difference)
1       Jan 01, 2020           
1       Jan 22, 2020
1       Feb 02, 2020
2      Jan 01, 2020
2      Jan 24, 2020
2      Feb 12, 2020

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data want;
set have;

by id;

num_days = dif(date);

if first.id then call missing(num_days);

run;

Use the DIF() function. 

 


@mahossain wrote:

i.e first # of days (difference)  will be missing and the 2nd will be difference of Jan 22, 2020-Jan 01, 2020 and so on by ID
ID       Date                   # of days (difference)
1       Jan 01, 2020           
1       Jan 22, 2020
1       Feb 02, 2020
2      Jan 01, 2020
2      Jan 24, 2020
2      Feb 12, 2020


 

View solution in original post

2 REPLIES 2
Reeza
Super User
data want;
set have;

by id;

num_days = dif(date);

if first.id then call missing(num_days);

run;

Use the DIF() function. 

 


@mahossain wrote:

i.e first # of days (difference)  will be missing and the 2nd will be difference of Jan 22, 2020-Jan 01, 2020 and so on by ID
ID       Date                   # of days (difference)
1       Jan 01, 2020           
1       Jan 22, 2020
1       Feb 02, 2020
2      Jan 01, 2020
2      Jan 24, 2020
2      Feb 12, 2020


 

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 535 views
  • 0 likes
  • 2 in conversation