I am successfully creating date macros, as seen from the put statement in the log. The odd thing is, I'm trying to append my log file name with these date macros and it is just plum not resolving in the log file name.
All of the following dates resolve just fine:
%LET DATE = %SYSFUNC(DATE(),DATE10.);
%LET HR = %SYSFUNC(SUBSTR(&TIME, 1, 2));
%LET MIN = %SYSFUNC(SUBSTR(&TIME, 4, 2));
%LET SEC = %SYSFUNC(SUBSTR(&TIME, 7, 2));
%PUT DATE = &DATE;
%PUT = &HR.;
%PUT = &MIN.;
%PUT = &SEC.;
And then I try to resolve macros within the log filename which doesn't work:
proc printto log = '\\sasprod\Finance\HealthAnalytics\Projects\Mental_Health_Build\Logs\MH_BUILD_&DATE&HR&MIN&SEC..log';
I have tried many different variations of date macros that will resolve in the put statement and then not in the log. I end up with filename MH_BUILD_&DATE&HR&MIN&SEC or whatever other unresolved date macro names I've tried creating.
Help much appreciated.
Use double quotes - " " instead of single.
Use double quotes - " " instead of single.
All the time I spent pouring over this...
I knew it'd be something simple. Thank You!!!
If you ran your program as a batch job then you can easily get a time-stamped SAS log file without doing any extra SAS coding.
I miss batch. It's not used in my current position.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: