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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
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

View solution in original post

8 REPLIES 8
data_null__
Jade | Level 19
1975  %put NOTE: %sysfunc(intnx(DTDAY,%sysfunc(datetime()),-1,same),datetime22.3);
NOTE: 19JAN2016:06:36:11.653
ksachar
Obsidian | Level 7

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. 

data_null__
Jade | Level 19
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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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);
ksachar
Obsidian | Level 7

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. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 5597 views
  • 2 likes
  • 4 in conversation