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.
Try using %SYSFUNC like the following:
%LET CURRENT_DAY=%sysfunc(TODAY());
Try using %SYSFUNC like the following:
%LET CURRENT_DAY=%sysfunc(TODAY());
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.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.