SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Brad39
Fluorite | Level 6

Hi,

 

I want to locate the last sunday of month but I am confused whether the following syntax is correct or not.

or there is any other way to locate it?

 

last sunday=INTNX ('WEEK', INTNX('MONTH', TODAY() , 0, 'E') , 0 , 'B')

 

Please if you could help here.

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Looks good to me. 

You take a date and shift it forward to the last day of the month. Then you shift that last day of the month back to the first day of the week the last day of the month is in. With SAS the first day of the week is Sunday.

View solution in original post

5 REPLIES 5
Patrick
Opal | Level 21

Looks good to me. 

You take a date and shift it forward to the last day of the month. Then you shift that last day of the month back to the first day of the week the last day of the month is in. With SAS the first day of the week is Sunday.

Brad39
Fluorite | Level 6

Thank alot

Ksharp
Super User

Or try another function : NWKDOM(n, weekday, month, year)

 

last_sunday=nwkdom( 5 , 1, 2 , 2020) ;

 

-- 5 is for the last week within a month

-- 1 is for sunday

Patrick
Opal | Level 21

@Ksharp 

Learned something new 🙂

Looks like there is a SAS function for almost everything. ....hopefully we will also get "call zero()/call value()" one day.

Ksharp
Super User

Patrick,

OP's statement is also brilliant , which remind me to learn this idea from yours .

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
  • 4840 views
  • 3 likes
  • 3 in conversation