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

Hi!

 

Brand spanking new to SAS.

 

I'm trying the following:

 

%LET CURRENT_DAY=TODAY();

 

 

RUN;

.

.

.

%put 'Today is ' &CURRENT_DAY.;

.

.

quit;

 

AND I GET:

 

'Today is' TODAY()

 

What do I need to do to get the value of TODAY() ?

 

THX.

 

1 ACCEPTED SOLUTION

Accepted Solutions
jebjur
SAS Employee

Try using %SYSFUNC like the following:

 

%LET CURRENT_DAY=%sysfunc(TODAY());

View solution in original post

3 REPLIES 3
jebjur
SAS Employee

Try using %SYSFUNC like the following:

 

%LET CURRENT_DAY=%sysfunc(TODAY());

Tater_Salad
Obsidian | Level 7
Awesome! Thank You!
ballardw
Super User

The question indicates perhaps you need to learn a bit more basic SAS coding before attempting the macro language. Macros are often not needed and your time would be better spent learning the basics.

 

Data _null_;

   currentdate = today();

   put  'Today is ' CURRENT_DAY;

run;

 

BUT this is likely not what you expect as the date is number of days and a format should be applied.

 

Data _null_;

   currentdate = today();

   put  'Today is ' CURRENT_DAY date9.;

run;

 

To use functions from the data step language you need to enclose the call within %sysfunc(today()) to tell the macro language to engage the data step function. Otherwise it only generates text.

 

Note that you may be able to use the automatic SAS variable &sysdate. Maybe. There are some details involved that you should read in the documentation.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1262 views
  • 0 likes
  • 3 in conversation