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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 464 views
  • 0 likes
  • 2 in conversation