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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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