BookmarkSubscribeRSS Feed
Elliott
Obsidian | Level 7

I am trying to create a data set with a list of all the weekend and US holiday dates like the example below, that will be for the entire 2019 year.

Is there an easy way to do that using SAS.  This calendar dataset is utilized in my production code but the group that created it seems to no longer be around so I don't think they will be creating a 2019 version. This dataset is used as exclusion criteria in my code.

 

Thanks

 

HolidayName

Year

Holiday_Date

New Year's Day

2018

Monday, January 01, 2018

Weekends

2018

Saturday, January 06, 2018

Weekends

2018

Sunday, January 07, 2018

Weekends

2018

Saturday, January 13, 2018

Weekends

2018

Sunday, January 14, 2018

Martin Luther King Day

2018

Monday, January 15, 2018

Weekends

2018

Saturday, January 20, 2018

Weekends

2018

Sunday, January 21, 2018

2 REPLIES 2
ballardw
Super User

And:   Weekend= WEEKDAY (somedatevalue) in (1,7);

 

https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.

 

So a data set created something like should get you started.

 

Data datelist;

do date = '01JAN2019'd to '31Dec2019'd;
   HolidayName='Weekend';
   if weekday(date) in (1,7) then output;
end;
HolidayName='Christmas'; date= holiday('Christmas',2019); output;
format date date9.; run;

Make sure to set a length for Holidayname long enough to hold the longest text as the above will set it to 7 characters which won't hold Christmas

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2381 views
  • 0 likes
  • 3 in conversation