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.);

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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