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;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 4359 views
  • 2 likes
  • 4 in conversation