DATA Step, Macro, Functions and more

macro variable from today()

Reply
N/A
Posts: 0

macro variable from today()

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;

....
Super Contributor
Super Contributor
Posts: 3,174

Re: macro variable from today()

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_;
N/A
Posts: 0

Re: macro variable from today()

Don't forget that you have an automatic system macro variable &SYSDATE, which gives you the date your SAS session started.
SAS Employee
Posts: 9

Re: macro variable from today()

You could also use this instead of the DATA step:

%let today=%sysfunc(today(),date7.);
Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 0 likes
  • 3 in conversation