I want to save the log file of a SAS program to a network drive every time the code runs. The saved log file name would contain the date & time that it was generated in order to have a unique name.
Any suggestions on how to do this please?
you can try to use the procedure
proc printto log="~/test.log";
run;
Thanks,
Jagadish
you can try to use the procedure
proc printto log="~/test.log";
run;
Thanks,
Jagadish
Thanks Jagadish, that answered my question!
Fethon Naoum
another approach you might like requires no code, just options you could put into the invocation command, or into one of the config files that sas uses when it starts
These are the options
-logparm (rollover=session write=immediate)
-log "...your path.../altlog.#Y-#m-d.#H-#M-#s.###p.#a.log"
It is the -LOG option which defines an alternative log file with these #directives which are replaced with year/month/day/time/processID values that are defined in the documentation for the option LOGPARM.
Depending on which release of SAS you use, they will also work for the -ALTLOG option.
Although the LOGPARM option was introduced to support the continuous working of SAS servers, with ROLLOVER= AUTO, ROLLOVER=SESSION provides the more-normal handling that a new LOG is written for each SAS session.
Although you might not need or want it, I left in a feature I copied from my working environments (for this example) because you might appreciate it too.
WRITE=IMMEDIATE ensures the log file is written directly new info should appear in the log, and not delayed until the write buffer is full.
Thanks Peter, that's an elegant way of doing it.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.