## Count number of hours, and or minutes, more than 24h

Occasional Contributor
Posts: 5

# Count number of hours, and or minutes, more than 24h

Hi,

I have a data set with wait time data.

exemple:

 Patient Admission date/time Left ER date time Wait time A 2015-11-02 5:00 2015-11-02 19:30 14:30:00 B 2015-11-05 8:12 2015-11-05 17:30 9:18:00 C 2015-11-14 5:00 2015-11-15 19:30 38:30:00 Total wait time 62:18:00

I would like to be able to count the total number (in hours and in minutes) waiting time in the room.

thank you

Super Contributor
Posts: 275

## Re: Count number of hours, and or minutes, more than 24h

Posted in reply to LVeilleux

Try this:

wait_time=intck('second',input(admission_dt,anydtdtm.), input(left_dt,anydtdtm.));
format wait_time time8.;

Esteemed Advisor
Posts: 5,626

## Re: Count number of hours, and or minutes, more than 24h

Posted in reply to LVeilleux

Wait duration is simply the difference between the datetimes. Give the difference a hhmm8. format to display hours (may be more than 24) and minutes.

waitTime = left_ER_DT - admission_DT;

format waitTime hhmm8.;

PG
Occasional Contributor
Posts: 5

## Re: Count number of hours, and or minutes, more than 24h

Hi, thank you for the answer,

I can calculate the wait for each patient using the difference between the datetimes but after that, I need to calculate the mean of all patient wait by day and doesn't seem that I can do just a mean

Esteemed Advisor
Posts: 5,626

## Re: Count number of hours, and or minutes, more than 24h

Posted in reply to LVeilleux

Which day? The day they got in, got out, or the total number of hour-person waited every day in ER?

PG
Occasional Contributor
Posts: 5

## Re: Count number of hours, and or minutes, more than 24h

Hi,

They ask me:  by month,day and hour of the day using the registration Date

They want the average wait in minutes and in hours (and not in this file exemple but I will need to give the information by service and by unit of admission)

 Patient Registration Date Admission date/time Left ER date time Wait time A 2015-11-02 2:00 2015-11-02 5:00 2015-11-02 19:30 14:30:00 B 2015-11-05 4:12 2015-11-05 8:12 2015-11-05 17:30 9:18:00 C 2015-11-14 3:00 2015-11-14 5:00 2015-11-15 19:30 38:30:00
Esteemed Advisor
Posts: 5,626

## Re: Count number of hours, and or minutes, more than 24h

Posted in reply to LVeilleux

Then it' s simple

``````proc sql;
create table waitTimes as
select
datepart(registrationDT) as registrationDate format=yymmdd10.,
mean(left_ER_DT-Admission_DT) as waitTime format=hhmm8.
from myData
group by calculated registrationDate;
quit;``````
PG
Occasional Contributor
Posts: 5

## Re: Count number of hours, and or minutes, more than 24h

Thank you, it's working well.

Line

Discussion stats
• 7 replies
• 491 views
• 0 likes
• 3 in conversation