Hi,
I've tried a few things and nothing worked so far. here is what I am trying to do
current query
proc sql;
select (date_end-date_start) as Calender_days
from
Table_A;
this query return calander days between start and the end date
I want the same query to now return only the work days minus Holidays (selected ones)... here is the script that I found to identify the holidays but I am unable to figure out the logic
data holidays ; length HolidayName $ 30 ; array WkDayShift [7] _temporary_ ( 1 5*0 -1 ) ; retain ShiftToggle /* 0 */ 1 ; do Year = 1971 to 2070 ; HolidayName = "New Year's Day" ; * 1 Jan if not Mon 2 Jan. ; HoliDate = holiday('newyear', year) ; dow = weekday(HoliDate) ; HoliDate = intnx( 'day', HoliDate, WkDayShift[dow] * ShiftToggle ) ; if not ( (dow EQ 7) and ShiftToggle ) then output ; HolidayName = "Martin Luther King Day" ; * 3rd Mon in Jan ; HoliDate = holiday('mlk', year) ; output ; HolidayName = "Presidents' Day" ; * 3rd Mon in Feb ; HoliDate = holiday('uspresidents', year) ; output ; HolidayName = "Memorial Day" ; * Last Mon in May ; HoliDate = holiday('memorial', year) ; output ; HolidayName = "Independence Day" ; * 4 Jul if not Mon 5 Jul or Fri 3 Jul ; HoliDate = holiday('usindependence',year) ; HoliDate = intnx('day', HoliDate, WkDayShift[ weekday(HoliDate) ] * ShiftToggle) ; output ; HolidayName = "Labor Day" ; * 1st Mon in Sep ; HoliDate = holiday('labor', year) ; output ; HolidayName = "Thanksgiving Day" ; *4th Thu in Nov ; HoliDate = holiday('thanksgiving', year) ; output ; HolidayName = "Christmas" ; * 25 Dec if not Mon 26 Dec or Fri 24 Dec ; HoliDate = holiday('christmas', year) ; HoliDate = intnx('day', HoliDate, WkDayShift[ weekday(HoliDate) ] * ShiftToggle) ; output ; HolidayName = "New Year's Eve" ; * Fri 31 Dec or not at all ; HoliDate = mdy(12, 31, year) ; if weekday(HoliDate) EQ 6 and ShiftToggle then output ; end ; keep year HolidayName HoliDate ; format HoliDate weekdate17. ; run ;
proc print data=holidays ; where year in (2017, 2018) ; by year ; id year ; run ;
Thanks in advance
... View more