DEV Community

Dutra
Dutra

Posted on

SAS Function isBusinessDay

This is an auxiliary function to isBrHoliday, demonstrated in the previous post, to validate whether a date is a business day, disregarding weekends and holidays. the code can be added along with the previous block inside proc fcmp.

proc fcmp outlib=work.sas_functions.dateFunctions;

    /*
    =================== 
     * FUNCTION:isBusinessDay
     * AUTHOR: Dutra - dutra@relevants.org
     * DESCRIPTION: Tests a date to validate if it is a 
Brazilian national holiday or non-business day, returning 0 or 1.
    ===================
    */
    function isBusinessDay(date);

        if weekday(date) in (1, 7) or isBrHoliday(date) = 1 then
            return(0);
        else return(1);

    endsub;


quit;

options cmplib=work.sas_functions;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)