DATA Step, Macro, Functions and more

How to find Nth business day incl holidays

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How to find Nth business day incl holidays

[ Edited ]

Our database updates on the 8th business day of the month so I need to create some date parameters that will depend whether or not the current day falls on or before/after the 8th business day.

 

Just to be clear, I'm just asking for code to identify the 8th business day, not code for creating the date parameters.  :-)

 

I currently use SAS EG 7.13 and SAS 9.


Accepted Solutions
Solution
‎03-19-2018 09:45 AM
Super User
Posts: 22,853

Re: How to find Nth business day incl holidays

business_day = intnx('weekday', intnx('month', today(), 0, 'b'), 8);

 

If you have custom intervals, which you likely do, you need to build your own custom calendar to account for the holidays and then you can use that interval instead. 

 

 

View solution in original post


All Replies
Super User
Posts: 22,853

Re: How to find Nth business day incl holidays

 

You can use TODAY() to generate todays date and then DAY() to get the day of the month.

 

It's not quite clear what you're looking for besides that.

Solution
‎03-19-2018 09:45 AM
Super User
Posts: 22,853

Re: How to find Nth business day incl holidays

business_day = intnx('weekday', intnx('month', today(), 0, 'b'), 8);

 

If you have custom intervals, which you likely do, you need to build your own custom calendar to account for the holidays and then you can use that interval instead. 

 

 

New Contributor
Posts: 2

Re: How to find Nth business day incl holidays

Thanks!   I was kind of hoping for a way around the custom calendar thing.   I tried a set of code that employed the holiday function but even that had flaws.

 

But thanks for the tip!

Super User
Posts: 22,853

Re: How to find Nth business day incl holidays

The custom calendar isn't as hard as it seems though it was intimidating the first time I tried to figure it out.

 

If you're in US you can use the following to make your holiday lists:

http://www.sascommunity.org/wiki/Generating_Holiday_Lists

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 85 views
  • 2 likes
  • 2 in conversation