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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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