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.
aazzarello
Fluorite | Level 6

I'm trying to get the last day of the week ending Tuesday for a Date column in my dataset. I've been using the intnx function with the optional 'e' identifier at the end, but I get the week ending Saturday. Just subtracting days from the output doesn't quite work either due to some days falling on different weeks. Code below:

proc sql;
create table erewq as 
select 
intnx('week',t1.'Period Dt'n , 0, 'e') as DTM2 format=date9.,
t1.'period dt'n
from WORK.EDJEC t1
;quit;


Is there another function that would perform this better, or a different way to use the intnx function? Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @aazzarello,

 

Shift the start of the week to Wednesday by using 'week.4' instead of 'week' in the first argument of the INTNX function, then the weeks will end on Tuesday as desired (see documentation of the shift index).

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @aazzarello,

 

Shift the start of the week to Wednesday by using 'week.4' instead of 'week' in the first argument of the INTNX function, then the weeks will end on Tuesday as desired (see documentation of the shift index).

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
  • 1 reply
  • 554 views
  • 2 likes
  • 2 in conversation