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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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