I am tasked with developing a report that will run daily. There are 11 error checks, for 9 of 11 error checks I need to report daily.
The problems is that 2 of the error checks are monthly and only need to run 1 time each month around the 2nd business day.
Is there any way to create a variable that will set to 1 if it is the second business day of the month?
Or maybe if it is easier the 2nd Tuesday of the month?
Thanks in advance.
You can calculate the second Tuesday as follows. For the 2nd business day you will need to define business day. Check out Holiday function and or custom date intervals.
data _null_;
date = today();
year = year(date);
int_date = intnx('month',date,0,'begin');
count = 0;
do until (int_date > date);
if
weekday(int_date) not in (1,7) and
int_date ne holiday('easter',year) + 1 /* easter monday */ and
int_date ne holiday('easter',year) + 50 /* pentecost monday */ and
int_date ne mdy(1,1,year) and
int_date ne mdy(7,4,year)
/* treat additional holidays as required */
then count = count + 1;
int_date = int_date + 1;
end;
call symput('num_workdays',strip(put(count,best.)));
run;
Now you can use &num_workdays as the number of business days in the month.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.