Search code examples
sassas-macro

how to get next friday in sas


friday=intnx('week.5',today(),0)

Is this correct logic to get next Friday?


Solution

  • In SAS 1 is Sunday, so you need to check for 6 instead.

    data test;
    next_friday=intnx('week.6',today(),1);
    following_friday=intnx('week.6',today(),2);
    format next_friday date9. following_friday date9. ;
    put _all_;
    run;
    

    Output: today is 1-MAY-2018

    next_friday=04MAY2018 following_friday=11MAY2018
    

    Note: According to SAS documentation 0 should show the current week but it shows the previous week because we used week.6 in our case here but when using 1 instead the correct Friday is picked.