/*** TIP 00384 ***/
/*********************************************************/
/*  Calculate the last working day of the month = payday */
/*  Input parameter any date in the month                */
/*  Output : the payday                                  */
/*  Author: Lars L Jacobsen ljacobsen@csc.com            */
/*********************************************************/

%MACRO payday(month);
   INTNX('day',INTNX('month',&month,0,'end'),
          -(weekday(INTNX('month',&month,0,'end'))=7)
          -(weekday(INTNX('month',&month,0,'end'))=1)*2)
%MEND payday;

data testdate;
 date = '01jan2003'd; output;
 date = '01feb2003'd; output;
 date = '01mar2003'd; output;
 date = '01apr2003'd; output;
 date = '01may2003'd; output;
 date = '01jun2003'd; output;
 date = '01jul2003'd; output;
 date = '01aug2003'd; output;
 date = '01sep2003'd; output;
 date = '01oct2003'd; output;
 date = '01nov2003'd; output;
 date = '01dec2003'd; output;
run;

proc sql;
select date format=ddmmyy10.,
       INTNX('month',date,0,'end') AS lastday FORMAT=weekdate.,
       %payday(date) as payday format=ddmmyy10.
from testdate;
quit;