Hi All,
I am struggling in calculation actual length of stay which is given by days in between arrival date/time and discharge date time. I want to incorporate the time also as opposed to just calculating days.
So for example arrival datetime = 01/01/2019 7am and discharge date time = 01/03/2019 9pm
so the actual length of stay should be 2 days and 14 hours
I cannot upload the data due to privacy reason but attached is the data set screenshot.
Thank you so much in advance
best,
C
So how do you want the length of stay to be displayed in your desired data set? As a decimal number or as '2 days and 14 hours' or?
As a decimal like 12 hours if 3.5 days? or any standard format of actual LOS . I am not sure. My plan is to calculate the variance between GMLOS and Actual LOS .
data want;
set have;
delta_time=new_admit-new_dis;
days = floor(delta_time/86400);
hours = floor((delta_time-days*86400)/3600);
minutes = floor((delta_time-days*86400-hours*3600)/60);
run;
DateTimes make this easy:
number_of_seconds = new_dis - new_admit;
If you want to convert that to hours, divide by 3600.
It should be relatively easy to convert number of hours into any form that you would like.
data test;
arrival='01jan2019 07:00:00'dt;
discharge='03jan2019 21:00:00'dt;
time=discharge-arrival;
format arrival discharge datetime20.;
run;
YOU guys are AWESOME ...
Thank you 🙂
one more question:
How to calculate "average patient per hour"
I have patients account number and admit date/time for entire 2018 year
Show us what your data looks like for a usable code answer
I have encounter number , admit date and admit hour for entire 2018 data ( n = 55000) where each row represents the unique patient encounter. I need to calculate the average patient per hour .
There is an alternative (or perhaps call it an extension) to dividing by number of seconds, minutes, hours, etc - namely a format that displays something like
20D:12:30
which means 20 days, 12 hours, 30 minutes
proc format;
picture fdur
low-high= '%jD%0H:%0M' (datatype=datetime);
run;
data want;
set have;
duration=discharge-arrival;
format duration fdur.;
run;
Caveats:
picture fdur
low-high= '%jD%0H:%0M:%0S' (datatype=datetime);
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.