Help using Base SAS procedures

Weekdays in DATA SET

New Contributor
Posts: 3

Weekdays in DATA SET


Is there a command to show the working days a year in a data set?

Super User
Posts: 13,542

Re: Weekdays in DATA SET

Posted in reply to hugo_spss

You will need to qualify what you mean by "weekdays" or "workdays" in a data set. You can set a flag for a given SAS date type variable as to whethere it is a weekday but the code varies by national location.

For example in a data step given a SAS data variable called date:

WeekDayFlag = (weekday(date) in (2,3,4,5,6)); /* will set a value of 1 for Monday through Friday in most US installations and 0*/

And if you mean workdays to exclude certain holidays or observances you will need to define them. Also does the organization work on Saturday?

There is a Holiday function that return the date of some holidays for a given year but if you have something not on that list ...

You could modify the flag above say for a given holiday similar toSmiley Sadassumes "year" of data is 2013)

If date=holiday('easter',2013) then WeekDayFlag=0; /* assuming Easter isn't a day you want counted*/

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation