BookmarkSubscribeRSS Feed
hellind
Quartz | Level 8

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.

3 REPLIES 3
hellind
Quartz | Level 8

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))

art297
Opal | Level 21

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.

art297
Opal | Level 21

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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 save with the early bird rate—just $795!

Register now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 3310 views
  • 1 like
  • 2 in conversation