BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterClemmensen
Tourmaline | Level 20

Hi All.

 

Can you perhaps offer some knowledge here? Why does this

 

data _null_;
   start='01feb2016'd;
   end='29feb2016'd;
   numMondays=intck('weekday134567w' ,start, end);
   put numMondays;
run;

not result in numMondays=5?

 

Browsing the INTCK Documentation and Intervals Available to the Function, I would think that this gives me the number of 1 day week periods, considering Tuesday, Wednesday, Thursday, Friday, Saturday ans Sunday as weekend days = the number of Mondays. However, clearly this is not the case as NumMondays=4 in the code above and there are 5 Mondays in February of 2016. 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
First thing to check: INTCK captures the number of boundaries crossed. So if Feb 1 is a Monday it won't be counted.

View solution in original post

4 REPLIES 4
Astounding
PROC Star
First thing to check: INTCK captures the number of boundaries crossed. So if Feb 1 is a Monday it won't be counted.
PeterClemmensen
Tourmaline | Level 20

There we go. Thank you! Starring myself blind on this one.

Kurt_Bremser
Super User

Just to help with illustrating @Astounding 's point, run this for testing:

data _null_;
   start='01feb2016'd;
   end='29feb2016'd;
   numMondays=intck('weekday134567w' ,start, end);
   put numMondays;
run;

data _null_;
   start='31jan2016'd;
   end='29feb2016'd;
   numMondays=intck('weekday134567w' ,start, end);
   put numMondays;
run;

data _null_;
   start='01feb2016'd;
   end='01mar2016'd;
   numMondays=intck('weekday134567w' ,start, end);
   put numMondays;
run;

Only the second step returns 5, as the start is now before a Monday. Moving the end to a Tuesday does not change the result, so the boundary has to be 00:00 on a given day. 29feb is already past that boundary, but 01feb is not before it.

PeterClemmensen
Tourmaline | Level 20

Cool stuff. Thank you both 🙂

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 1898 views
  • 2 likes
  • 3 in conversation