Example 9.15 Determining the Number of U.S. Business Days between Two Dates

Goal

Determine the number of business days between two dates. Do not count specific holidays as business days.

Example Features

Featured StepDATA step
Featured Step Options and StatementsHOLIDAY, INTCK, and WEEKDAY functions

Input Data Set

Data set DAY_RANGES has two date variables, DAY1 and DAY2.

           DAY_RANGES

Obs          day1           day2
 1     07/01/2008     07/05/2008
 2     06/23/2008     06/27/2008
 3     05/19/2008     05/19/2009
 4     04/01/2008     04/05/2011
 5     01/23/2009     01/25/2009

Resulting Data Set

Output 9.15 BUSINESS_DAYS Data Set

 Example 9.15 BUSINESS_DAYS Obs day1 day2 totaldays workdays holidays 1 07/01/2008 07/05/2008 4 2 1 2 06/23/2008 06/27/2008 4 4 0 3 05/19/2008 05/19/2009 365 255 6 4 04/01/2008 ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.