I want to create a global macro for yesterdays date using sysfunc (without using today() ). And I want the output in datetime22.3 format. Couldn't figured out by myself.
2027 %put NOTE: %sysfunc(intnx(DTDAY,%sysfunc(datetime()),-1,begin),datetime22.3);
NOTE: 19JAN2016:00:00:00.000
You might want to read about INTNX
1975 %put NOTE: %sysfunc(intnx(DTDAY,%sysfunc(datetime()),-1,same),datetime22.3);
NOTE: 19JAN2016:06:36:11.653
Thanks. I just tried and I got the following output: 19JAN2016:11:03:57.512. Is there anyway I can get 19JAN2016:00:00:00.000 as an output. I want to oull up all the transaction from the begining of the day yesterday.
Thanks once again.
2027 %put NOTE: %sysfunc(intnx(DTDAY,%sysfunc(datetime()),-1,begin),datetime22.3);
NOTE: 19JAN2016:00:00:00.000
You might want to read about INTNX
Sorry, couple of questions:
Why do you need to keep a macro variable with today()-1, what is wrong with just using that?
Why can you not use today() function which does this processing, why try to re-implement it?
To put it in the log do:
%put %sysfunc(today(),datetime22.0);
I got the following output when I used your code.
01JAN1960:05:41:13
I hoep thats answers the question why I prefer using sysfunc.
Not really, you didn't mention that in the original request. You can merely modify the code slightly:
%put %sysfunc(today(),date9.):00:00:00.000;
Another method:
data _null_;
call symput('yesterday',put((today()-1)*86400,datetime22.3));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.