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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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