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).

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 177 views
  • 2 likes
  • 2 in conversation