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.
There we go. Thank you! Starring myself blind on this one.
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.
Cool stuff. Thank you both 🙂
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!
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.