BookmarkSubscribeRSS Feed
monday89
Fluorite | Level 6

I have the following tables were subjects have overlapping date/time but i need to cut them by certain time to calculate different measures

 

have table. For example row 1 has a longer duration but row 2 has short. I need to assign row 2 start time as new stop time for row 1and create a row 3 that has row 1 as new stop dt but with row 2 stop dt time as new start time for row 3. It can have more than 2 observations. 

 

patient start_time stop_time value1 value2
1 12/1/2019 0:00 12/1/19 22:12 1 4
1 12/1/2019 10:12 12/1/19 10:42 0.5 4

 

Want:

patient start_time stop_time value1 value2
1 12/1/2019 0:00 12/1/2019 10:12 1 4
1 12/1/2019 10:12 12/1/19 10:42 0.5 4
1 12/1/19 10:42 12/1/19 22:12 1 4

 

I have no idea how to start to be honest, 

 

I tried _n = n + 1 for start_time < stop_date but i have no idea

2 REPLIES 2
mkeintz
PROC Star

do you expect any instances of more than 2 overlapping time-spans.  Or is it always exactly 2?  In other words, how far ahead do you need to look to determine all the needed start/stop pairs?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
monday89
Fluorite | Level 6

Thats a great question . it can be more than 2

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 685 views
  • 0 likes
  • 2 in conversation