Help using Base SAS procedures

Min and max overlapping two date time points

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

Min and max overlapping two date time points

Hi I have a table that I need to determine the min and max time of 2 or 3 data time points...that is limited within hour of each point if it's greater I excluded

 

my data looks like this

 

id.     Number.      Start time.                      End time

1a.       23.           01/01/16. 11:01:00.        01/01/16 11:05:11

1a.        24.          01/01/16 11:02:00.          01/01/16 11:06:16

1a.       25.            01/01/16. 12:00:00.        01/0116 12:07:00

 

what I need here is just number 23 and 24 sine they over lap the 25 it exceeds the hour from the first 2 ....I would need 23 and 24 in one roll

id. Number. Start time. End time.                         Id.  Number.                Start time.                           end time 
1a. 23. 01/01/16. 11:01:00. 01/01/16 11:05:11.  1a        24                   01/01/16. 11:02:00.          01/01/16 11:06:16

I would need the min start time of number and max end time from number first 

 

thanks in advance

 

 


Accepted Solutions
Solution
‎01-18-2016 01:47 PM
Super User
Posts: 19,867

Re: Min and max overlapping two date time points

And if there was 4 overlap how would you want it to look like? Each entry into a group?

 

You can use the lag function to create groups and determine if there's an overlap. Once your groups are assigned you can then use various transpose mechanisms to transpose your data. 

 

 

View solution in original post


All Replies
Super User
Posts: 19,867

Re: Min and max overlapping two date time points

Can you have multiple overlaps?

What happens when there's no overlaps?

What do you want the final dataset to look like for all records, include only overlaps?

Regular Contributor
Posts: 240

Re: Min and max overlapping two date time points

Yes I'm grouping it by Id. So if there could be up to 4 overlap if there is no overlap than I don't need that I just need where there was overlap ...
For example out put

1a. 23. 01/01/16. 11:01:00. 01/01/16 11:05:11.  1a        24                   01/01/16. 11:02:00.          01/01/16 11:06:16

would be one roll for the ones that are over lap

Solution
‎01-18-2016 01:47 PM
Super User
Posts: 19,867

Re: Min and max overlapping two date time points

And if there was 4 overlap how would you want it to look like? Each entry into a group?

 

You can use the lag function to create groups and determine if there's an overlap. Once your groups are assigned you can then use various transpose mechanisms to transpose your data. 

 

 

Regular Contributor
Posts: 240

Re: Min and max overlapping two date time points

Sorry forgot to mention that i need min and max for example if we have 3 or 4 entries same id same number get the min and max from date time that falls within an hour of min an max longer than hr I will exclude it ...after that I would like to see if the min and max date time field overlaps with the other number but same id ... thanks again
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 332 views
  • 0 likes
  • 2 in conversation