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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.