BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jaime
Fluorite | Level 6

Is there a way to generate a list of holidays (dates) referenced by the sas Holiday function.

Are these dates stored in a sashelp view?

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Couldn't you just roll your own by copying that list, excluding the dates you don't want, and including the years you want?  E.g.,

data holidays;

  informat holiday $20.;

  infile cards truncover;

  input holiday;

  cards;

BOXING           Boxing Day           December 26

CANADA           Canadian Independence Day           July 1

CANADAOBSERVED           Canadian Independence Day observed           July 1, or July 2 if July 1 is a Sunday

CHRISTMAS           Christmas           December 25

COLUMBUS           Columbus Day           2nd Monday in October

EASTER           Easter Sunday           date varies

FATHERS           Father's Day           3rd Sunday in June

HALLOWEEN           Halloween           October 31

LABOR           Labor Day           1st Monday in September

MLK           Martin Luther King, Jr. 's birthday           3rd Monday in January beginning in 1986

MEMORIAL           Memorial Day           last Monday in May (since 1971)

MOTHERS           Mother's Day           2nd Sunday in May

NEWYEAR           New Year's Day           January 1

THANKSGIVING           U.S. Thanksgiving Day           4th Thursday in November

THANKSGIVINGCANADA           Canadian Thanksgiving Day           2nd Monday in October

USINDEPENDENCE           U.S. Independence Day           July 4

USPRESIDENTS           Abraham Lincoln's and George Washington's birthdays observed           3rd Monday in February (since 1971)

VALENTINES           Valentine's Day           February 14

VETERANS           Veterans Day           November 11

VETERANSUSG           Veterans Day - U.S. government-observed           U.S. government-observed date for Monday-Friday schedule

VETERANSUSPS           Veterans Day - U.S. post office observed           U.S. government-observed date for Monday-Saturday schedule (U.S. Post Office)

VICTORIA           Victoria Day           Monday on or preceding May 24

;

data want;

  set holidays;

  do year=2005 to 2011;

    holiday_date=holiday(holiday,year);

    output;

  end;

run;

View solution in original post

6 REPLIES 6
Jaime
Fluorite | Level 6

Let me be a bit more specific about what I need.

I have a set of dates going back 6 years. I need to corss-reference my set of dates with the SAS holiday database so I can exclude past holidays from my dataset.

art297
Opal | Level 21

Couldn't you just roll your own by copying that list, excluding the dates you don't want, and including the years you want?  E.g.,

data holidays;

  informat holiday $20.;

  infile cards truncover;

  input holiday;

  cards;

BOXING           Boxing Day           December 26

CANADA           Canadian Independence Day           July 1

CANADAOBSERVED           Canadian Independence Day observed           July 1, or July 2 if July 1 is a Sunday

CHRISTMAS           Christmas           December 25

COLUMBUS           Columbus Day           2nd Monday in October

EASTER           Easter Sunday           date varies

FATHERS           Father's Day           3rd Sunday in June

HALLOWEEN           Halloween           October 31

LABOR           Labor Day           1st Monday in September

MLK           Martin Luther King, Jr. 's birthday           3rd Monday in January beginning in 1986

MEMORIAL           Memorial Day           last Monday in May (since 1971)

MOTHERS           Mother's Day           2nd Sunday in May

NEWYEAR           New Year's Day           January 1

THANKSGIVING           U.S. Thanksgiving Day           4th Thursday in November

THANKSGIVINGCANADA           Canadian Thanksgiving Day           2nd Monday in October

USINDEPENDENCE           U.S. Independence Day           July 4

USPRESIDENTS           Abraham Lincoln's and George Washington's birthdays observed           3rd Monday in February (since 1971)

VALENTINES           Valentine's Day           February 14

VETERANS           Veterans Day           November 11

VETERANSUSG           Veterans Day - U.S. government-observed           U.S. government-observed date for Monday-Friday schedule

VETERANSUSPS           Veterans Day - U.S. post office observed           U.S. government-observed date for Monday-Saturday schedule (U.S. Post Office)

VICTORIA           Victoria Day           Monday on or preceding May 24

;

data want;

  set holidays;

  do year=2005 to 2011;

    holiday_date=holiday(holiday,year);

    output;

  end;

run;

Jaime
Fluorite | Level 6

That's a good idea.

I guess I just assumed there was some view or table that had these.

art297
Opal | Level 21

There might be but, since (according to the documentation) one can't add holidays to it, I've never looked for one.  On the other hand, at least this way you can exclude any days that you don't want considered.

Howles
Quartz | Level 8

It's somewhat unlikely that the holiday set which SAS uses will conform to the holiday set appropriate to your business. For techniques to generate custom holiday lists, see

   http://www.sascommunity.org/wiki/Generating_Holiday_Lists

Unfortunately these cannot be utilized with the HOLIDAY function.

Jaime wrote:

Let me be a bit more specific about what I need.

I have a set of dates going back 6 years. I need to corss-reference my set of dates with the SAS holiday database so I can exclude past holidays from my dataset.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 5369 views
  • 0 likes
  • 3 in conversation