BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jyuen204
Obsidian | Level 7

Apologies for the rather simplistic question. But I have a date set I generate in the code to reference.

 

REPORTDATE = intnx('Week',today(),-1,'E');

CW_END          = intnx('Week',ReportDate,0,'E');

 

This gives me the most recent Saturday that passed for a report I generate. I need to be able to get this exact Date in the previous year. So in this case March 7 2020 is the date generated from above code. I need to get March 7 2019. I would use a hard coded calculation but that would mess up in Leap years like this year.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
oneyearago=intnx('year',cw_end,-1,'s');
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
oneyearago=intnx('year',cw_end,-1,'s');
--
Paige Miller
Jyuen204
Obsidian | Level 7

Thanks so much!

Reeza
Super User
The last parameter in the INTNX function is the alignment parameter. The option you're looking for is 'same' which will move it to the same date. Verify it treats leap years the way you want and you're good to go. You can also extract the month day and increment the year and use MDY() BUT that won't work for leap years so INTNX() is safer.

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