Hello,
I have found the holiday function to check if a particular date is an holiday (https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lefunctionsref/n1joh87ts4uj0un12b7je5ha4bge.htm)
However the Saint-Jean Baptise day is an holiday in the province of Quebec which is june 24.
Does this holiday exist with that function ?
According to the SAS Documentation, no it does not. However, have a look at the paper "Sometimes One Needs an Option with Unusual Dates" for a solution to the problem.
Hello @alepage,
It looks like the DATEKEYS procedure (in conjunction with the EVENTDS= system option) is designed for this purpose (i.e., adding a new holiday to the existing SAS-supplied holiday definitions). It is experimental in my fairly old SAS 9.4M5 release.
/* Define a new holiday */
proc datekeys;
datekeydef SAINT_JEAN_BAPTISTE_DAY='24JUN2000'd / period=year; /* The year (2000) is irrelevant. */
datekeydata out=JBdays;
run;
/* Make the new definition available */
options eventds=(JBdays);
/* Use the new holiday like any other holiday */
data _null_;
length holiday $50;
do date='25DEC2020'd, '24JUN2021'd, '17APR2022'd;
holiday=holidayname(date);
put date :date9. holiday;
end;
d=holidaynx('SAINT_JEAN_BAPTISTE_DAY',today(),0);
put / 'The most recent Saint-Jean-Baptiste Day was ' d worddate.-l +(-5) '.';
run;
Result in the log:
25DEC2020 CHRISTMAS 24JUN2021 SAINT_JEAN_BAPTISTE_DAY 17APR2022 EASTER The most recent Saint-Jean-Baptiste Day was June 24, 2024.
Really nice explanation and sample code, @FreelanceReinh!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.