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: 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!

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