Hi all,
I am trying to calculate the time from the last tube feed (tube_stopped) to the time of surgery. Each patient has multiple tube stop times and also multiple surgeries (date_procedure). I want to create a new variable that calculates this called "Time from last tube feed to procedure" in hours....
Data have:
ID tube_stopped date_procedure
7 12Jul17:02:00:00 13JUL17:13:00:00
7 01AUG17:15:00:00 01AUG17:22:00:00
7 20JUL17:07:35:00 20JUL17:22:00:00
1 29JUL16:01:00:00 29JUL16:23:00:00
1 12AUG16:16:00:00 12AUG16:22:00:00
Data want:
ID tube_stopped date_procedure time from last tube feed to procedure
7 01AUG17:15:00:00 01AUG17:22:00:00 2.4
1 12AUG16:16:00:00 12AUG16:22:00:00 5.7
What does the LAG function do?
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!
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.