DATA EXAMPLE;
START = '05APR2014:09:00:00'DT;
END = '08APR2014:10:25:16'DT;
DAYS = INTCK('DAYS', DATEPART(START), DATEPART(END);
WEEKDAYS = INTCK('WEEKDAYS', DATEPART(START), DATEPART(END);
RUN;
Why does it return DAYS = 3?
I was expecting DAYS = 4, and WEEKDAYS = 2.
I will be reading the manual, but some explanation from the community will help.
I mean whatever is the behaviour, I was expecting it should apply to both DAYS and WEEKDAYS.
It screwed my logic: Turnaound Time In Hours = INTCK(HOURS) - 24 * (INTCK(DAYS) - INTCK(WEEKDAYS))
intck is counting the number of boundaries crossed. From Apr 5, one has to cross six, then seven, then eight to arrive at eight, i.e., 3 days.
For weekdays, it is the same thing. From Apr 5, the first weekday crossed is the 7th, then the 8th, or 2.
As for you calculation of hours, IF you are assuming 24 valid hours in each workday, and that start and end will ALWAYS be workdays, then you could use something like:
DATA EXAMPLE;
START = '05APR2014:09:00:00'DT;
END = '08APR2014:10:25:16'DT;
DAYS= INTCK('DAYS', DATEPART(START), DATEPART(END));
WEEKDAYS = INTCK('WEEKDAYS', DATEPART(START), DATEPART(END));
if days lt 1 then Turnaound_Time_In_Hours=(timepart(end)-
timepart(start)/(60*60));
else do;
Turnaound_Time_In_Hours=(24*60*60-timepart(start)+(weekdays-1)*
(24*60*60)+timepart(end))/(60*60);
end;
RUN;
That will produce a calculation of 49.42 hours for your example.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.