BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

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 ?

4 REPLIES 4
SASJedi
Ammonite | Level 13

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. 

Check out my Jedi SAS Tricks for SAS Users
FreelanceReinh
Jade | Level 19

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.
SASJedi
Ammonite | Level 13

Really nice explanation and sample code, @FreelanceReinh

Check out my Jedi SAS Tricks for SAS Users

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 936 views
  • 7 likes
  • 4 in conversation