DATA Step, Macro, Functions and more

Using INTCK day comparison question

Regular Contributor
Posts: 179

Using INTCK day comparison question

data appeals1;

set appeals;



In this code I am getting the number of days between lm_set_up_dt and _585(which is a date)

I believe the ‘day’ function does not consider holidays and weekends it just provides a straight day difference.

Is there a way to have ‘day’ account for this by assigning the closest business day.(ie if one of the dates falls on Sunday can ‘day’ increment to Monday

(ie if _585 falls on Sunday 9/21/14 the code would allow _585 to increment to Monday 9/22/14 for calculation purposes.  In our company we do have a previous business day variable called &pbday.  I may need to learn how ‘day’ is read by sas

Super User
Posts: 23,771

Re: Using INTCK day comparison question

Look into 'weekday' instead of 'day', but it depends on your question.

Otherwise you can test if _585 is a day on Sat/Sun and increment. If you want to account for holidays it's more complicated.

data appeals1;

set appeals;

if day(_585)=7 then date=_585+2;/*Saturday*/

if day(_585)=1 then date=_585+1;/*Sunday*/


age_585_v2=intck('weekday', lm_set_up_dt, date);


Respected Advisor
Posts: 4,736

Re: Using INTCK day comparison question

intck() will return the difference between to dates based on the interval you're using. With "day" it is the number of days between 2 dates.

There are other intervals. "weekday" is eventually what you're after: SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition

Weekday will give you the number of - as it says - week days between 2 dates (with Saturday and Sunday treated as week-end).

I'm not sure that I fully understand what you're after so won't try to take this further. Run below code and let us know if this gives you what you're after.

Holidays are regional so there is no general interval out of the box available (except for US wide valid holiday days). You can create your own custom interval to take regional holidays into account. It's all documented under the link I've posted.

data test;

  format day_of_week downame.;

  format lm_set_up_dt _585 date9.;


  do _585='18Sep2014'd, '19Sep2014'd, '20Sep2014'd, '21Sep2014'd, '22Sep2014'd, '23Sep2014'd;







Trusted Advisor
Posts: 3,215

Re: Using INTCK day comparison question

In the documentation link by Patrick also the intervalds option with custom intervals is mentioned.

You can define and use any interval definition as you like including own defined holidays business working days or business service hours. 

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation