SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Rhodochrosite | Level 12

Hi Everyone,

I would like SAS to return previous working day.

Can you please help?

Thanks,

HHC

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The basic function is:

 

prevWeekDay = intnx("WEEKDAY", myDate, -1);

PG

View solution in original post

5 REPLIES 5
ballardw
Super User

Define "working day".

There really is not a universal definition for that. When I was in the US Army every day was a "working day".

If Holidays are to be excluded then which ones, and in which country (some holidays of the same name are celebrated on different calendar dates in different countries).

hhchenfx
Rhodochrosite | Level 12

Hi,

I meant simple US business day or normal week day.

Thanks,

HHC

 

PGStats
Opal | Level 21

The basic function is:

 

prevWeekDay = intnx("WEEKDAY", myDate, -1);

PG
hhchenfx
Rhodochrosite | Level 12

Thank you so much!

HHC

ballardw
Super User

@hhchenfx wrote:

Hi,

I meant simple US business day or normal week day.

Thanks,

HHC

 


I'll reiterate: there ain't such a thing.  If you mean to exclude Federal Holidays on the observed days that's fine, say so but many organization pick and choose which to follow. The SAS Holidayname function returns the names of holidays associated with a given date. So you can test a candidate date to see if it is one of the holidays you expect to observe. If it is then use the INTNX function to get the previous day to test.

When I worked for a University they did not observe Columbus Day or Veterans day.

Many many companies work every day of a typical week and only observe a very few holidays.

A survey company I worked for that typically worked Saturdays  would not work on Saturdays that coincided with certain sporting events.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 1820 views
  • 1 like
  • 3 in conversation