I extracted some code(from SAS communities) to calculate the nth business day of the month. It is a little off. I was testing the code to make sure it returned the 3rd day of the month. I noticed Jul ,Aug, and Oct were giving me the 4th day instead. All these months have 31 days so wondering if that is the reason. I want the 3 day of the month and will adjust for holidays for Jan, Jul and Sept only when it falls on a weekend. Can anyone confirm what is happening in these months and maybe how to accommodate the 1 day difference. Does SAS have a US holilday calendar? data test; format business_day1 business_day2 business_day3 business_day4 business_day5 date9.; business_day1 = intnx('weekday', intnx('month', '23jun2024'd, 0, 'b'), 3); business_day2 = intnx('weekday', intnx('month', '18jul2024'd, 0, 'b'), 3); business_day3 = intnx('weekday', intnx('month', '06aug2024'd, 0, 'b'), 3); business_day4 = intnx('weekday', intnx('month', '11sep2024'd, 0, 'b'), 3); business_day5 = intnx('weekday', intnx('month', '25oct2024'd, 0, 'b'), 3); run; The 'weekday' interval calculates the nth business day, skipping weekends. The discrepancy likely arises because the INTNX function starts counting business days from the first day of the month. If the first day of the month falls on a weekend, the calculation might push the nth business day forward.
... View more