Hi,
I am using date functions like today(), intnx etc. in my code.
Is there any way to point SAS date to yesterday at starting of the session ?
Example:-
data _null_;
call symput('run_dt', put(today(),yymmddn8.)); -->As per exisiting logic, this will return today's date.
run;
Is there any way to define SAS date prior to the above step, so by default it will point to yesterday's date ?
Note - I don't want to use today()-1
Please share your thoughts.
@AshokD wrote:
Hi,
My code has about 2k+ lines , they have used today() functions in so many places in the code. For some reason I need to run the job to pull data as of yesterday. Instead of changing the code today()-1 in all the places, is there any way to define current date as yesterday at the starting of the code so that today() function resolves to yesterday in all the logics placed in the code.
Is there any possibility ?
No, unless you reset the SAS server's system clock.
Do a search and replace in your code, and replace every occurence of today() with
&todays_date.
At the beginning of your code, insert
%let todays_date=%eval(%sysfunc(today()) - 1);
Now you only need to change this line in the future.
Hi @AshokD
Would you like to identify the day before today or the day before the opening of the SAS session?
It can be quite different. In the last case, it would be better to use &sysdate rather than today().
Best,
Hi,
My code has about 2k+ lines , they have used today() functions in so many places in the code. For some reason I need to run the job to pull data as of yesterday. Instead of changing the code today()-1 in all the places, is there any way to define current date as yesterday at the starting of the code so that today() function resolves to yesterday in all the logics placed in the code.
Is there any possibility ?
In short: no.
The longer answer: today() is what it is: today.
Regards,
Jan.
@AshokD wrote:
Hi,
My code has about 2k+ lines , they have used today() functions in so many places in the code. For some reason I need to run the job to pull data as of yesterday. Instead of changing the code today()-1 in all the places, is there any way to define current date as yesterday at the starting of the code so that today() function resolves to yesterday in all the logics placed in the code.
Is there any possibility ?
No, unless you reset the SAS server's system clock.
Do a search and replace in your code, and replace every occurence of today() with
&todays_date.
At the beginning of your code, insert
%let todays_date=%eval(%sysfunc(today()) - 1);
Now you only need to change this line in the future.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.