BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have the following bit of code, at the very beginning of a program being invoked by a batch file. The macro variable that is being derived from the today() function is not created -- why not? When I open the program, highlight and run this bit of code, it works.

data _null_;
call symput ('today',put(today(),date7.));
run;

proc printto log="P:\Log\AutoRun_&today..log" NEW; run;
proc printto print="P:\Log\AutoRunt_&today..lst" NEW; run;

....
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The standalone SAS snippet code below worked for me, as well. You will need to add some diagnostics to your SAS program (similar to the %PUT below) and test the macro variable value at points in your program execution -- pay attention to how global and local macro variable resolution works - topic referred to as "scope of macro variables" and can be found at the SAS support http://support.sas.com/ website for your reference.

Scott Barry
SBBWorks, Inc.

data _null_;
call symput ('today',put(today(),date7.));
run;

%put _global_;
deleted_user
Not applicable
Don't forget that you have an automatic system macro variable &SYSDATE, which gives you the date your SAS session started.
Russ_SAS
SAS Employee
You could also use this instead of the DATA step:

%let today=%sysfunc(today(),date7.);

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

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