11-03-2013 09:00 PM
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?
11-04-2013 04:45 AM
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.
Need further help from the community? Please ask a new question.