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

I have formula for next Sunday and previous Monday of the week.

SUNDAY:   intnx('week.1',datepart(ACTVN_DAT),1)

Monday:   intnx('WEEK.2',datepart(ACTVN_DAT),0)

 

But I realized that it is giving me next Sunday if my ACTVN_DAT falls on Sunday itself (which tells formula is good). Example is below:

 

sasuser_sk_0-1616446494183.png

 

How can I amend my formula to keep my Next_Sunday as it is if it falls on Sunday. This is what I want in my data:

sasuser_sk_1-1616446862038.png

March 21st & Jan 3rd was Sunday. So I want Next_Sunday as 03/21/2021 & 01/03/2021 respectively. However. Jan 21st is Thursday so my formula works right for this date.

 

Thanks for your help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @sasuser_sk,

 

Just subtract one day before applying INTNX:

Next_Sunday=intnx('week',datepart(ACTVN_DAT)-1,1);

(The ".1" after "week" is redundant.)

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @sasuser_sk,

 

Just subtract one day before applying INTNX:

Next_Sunday=intnx('week',datepart(ACTVN_DAT)-1,1);

(The ".1" after "week" is redundant.)

sasuser_sk
Quartz | Level 8

Thank you @FreelanceReinh . This worked just fine.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 2 replies
  • 758 views
  • 0 likes
  • 2 in conversation