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

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!

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