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

Dear All,

 

Good morning ! I need to find tuesday date of the week dynamically. 

 

For instance today date is 23-05-2018, when I run my code the date should be assigned to  22-05-2018

 

Another instance if run the code next week i.e 28-05-2018 , the date value should be assigned to 29-05-2018..

 

Please help to provide advise. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

INTNX(). 

Align it to the beginning of the week and then add 2. Check the docs for the details. 

 

Tuesday = intnx('week', today(), 0, 'b') + 2;

 


@dhruvakumar wrote:

Dear All,

 

Good morning ! I need to find tuesday date of the week dynamically. 

 

For instance today date is 23-05-2018, when I run my code the date should be assigned to  22-05-2018

 

Another instance if run the code next week i.e 28-05-2018 , the date value should be assigned to 29-05-2018..

 

Please help to provide advise. Thank you.


 

View solution in original post

3 REPLIES 3
Reeza
Super User

INTNX(). 

Align it to the beginning of the week and then add 2. Check the docs for the details. 

 

Tuesday = intnx('week', today(), 0, 'b') + 2;

 


@dhruvakumar wrote:

Dear All,

 

Good morning ! I need to find tuesday date of the week dynamically. 

 

For instance today date is 23-05-2018, when I run my code the date should be assigned to  22-05-2018

 

Another instance if run the code next week i.e 28-05-2018 , the date value should be assigned to 29-05-2018..

 

Please help to provide advise. Thank you.


 

dhruvakumar
Obsidian | Level 7
Dear Reeza,

Thank a lot.It working fine.
PGStats
Opal | Level 21

This is reliably done with SAS date interval functions:

 

data test;
do date = '01may2018'd to '31may2018'd;
    tuesday = intnx("day", intnx("week", date, 0), 2);
    output;
    end;
format date tuesday yymmdd10.;
run;

proc print data=test noobs; run;

i.e. find the date of the beginning of the week (a Sunday) and then move forward two days.

 

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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