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

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 1883 views
  • 0 likes
  • 3 in conversation