proc fcmp outlib = work.funcs.dt; /*use the function compiler procedure*/ function nextworkday(startday, interval);/*define a custom function*/ x= intnx("weekday1w",startday,interval);/*interval is the number of days after which you want to check for a business day*/ if x not in &holidays then return(x); else return(nextworkday(x,interval-(interval-1)));/*use recursion to check if day next day after interval falls on a holiday*/ endsub; quit; options cmplib=work.dt; %let holidays=("01JAN2018"d, "16FEB2018"D, "17FEB2018"D, "30MAR2018"D, "01MAY2018"D, "29MAY2018"D, "15JUN2018"D, "09AUG2018"D, "22AUG2018"D, "06NOV2018"D, "25DEC2018"D);/*These are singapore holidays for FY '18*/ %let startdate="01jan2018"d; %let enddate="31dec2018"d; data test; do i= intnx("month",&startdate,0,"b") to intnx("month",&enddate,0,"e"); j=put(i,date9.); z=nextworkday(i,3); format z date9.; output; end; run;
... View more