BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
knighsson
Obsidian | Level 7

Hello 

 

I want to combine the same date together and calculate how many days, could you please let me know how to do this?

The original dataset

ID DATE XX YY
1 04/10/13    
1 04/10/13  

 

1 05/10/13    
1 06/10/13    
2 04/10/13    
2 04/10/13    
2 04/10/13    
       
       
       

the ideal dataset

ID DATE number of same date YY
1 04/10/13  2  
1 05/10/13 1

 

1 06/10/13 1  
2 04/10/13 3  
       
       
       
       
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use PROC FREQ, result will be in the WANT data set. 

 

proc freq data=have noprint;
table id*date / out=want list;
run;

@knighsson wrote:

Hello 

 

I want to combine the same date together and calculate how many days, could you please let me know how to do this?

The original dataset

ID DATE XX YY
1 04/10/13    
1 04/10/13  

 

1 05/10/13    
1 06/10/13    
2 04/10/13    
2 04/10/13    
2 04/10/13    
       
       
       

the ideal dataset

ID DATE number of same date YY
1 04/10/13  2  
1 05/10/13 1

 

1 06/10/13 1  
2 04/10/13 3  
       
       
       
       

 

View solution in original post

2 REPLIES 2
Reeza
Super User

Use PROC FREQ, result will be in the WANT data set. 

 

proc freq data=have noprint;
table id*date / out=want list;
run;

@knighsson wrote:

Hello 

 

I want to combine the same date together and calculate how many days, could you please let me know how to do this?

The original dataset

ID DATE XX YY
1 04/10/13    
1 04/10/13  

 

1 05/10/13    
1 06/10/13    
2 04/10/13    
2 04/10/13    
2 04/10/13    
       
       
       

the ideal dataset

ID DATE number of same date YY
1 04/10/13  2  
1 05/10/13 1

 

1 06/10/13 1  
2 04/10/13 3  
       
       
       
       

 

knighsson
Obsidian | Level 7
Thank you!

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