This function defines a new date by calculating it, starting from the informed one plus the number of working days provided as parameters. When using negative days, it returns previous dates.
proc fcmp outlib=work.sas_functions.dateFunctions;
/*
===================
* FUNCTION:setDateByNumberBDays
* AUTHOR: Dutra - dutra@relevants.org
* DESCRIPTION: Defines a new date by calculating the
number of working days provided as a parameter.
When using negative days it returns previous dates.
===================
*/
function setDateByNumberBDays(date, numberDays);
numberBDays = 0;
do while (numberBDays < abs(numberDays));
if numberDays > 0 then
date = date + 1;
else
date = date - 1;
if isBusinessDay(date) then
numberBDays = numberBDays + 1;
end;
return(date);
endsub;
quit;
Top comments (0)