Help using Base SAS procedures

Saving log files

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Saving log files

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?


Accepted Solutions
Solution
‎11-03-2013 09:30 PM
Trusted Advisor
Posts: 1,128

Re: Saving log files

you can try to use the procedure

proc printto log="~/test.log";

run;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎11-03-2013 09:30 PM
Trusted Advisor
Posts: 1,128

Re: Saving log files

you can try to use the procedure

proc printto log="~/test.log";

run;

Thanks,

Jagadish

Thanks,
Jag
Contributor
Posts: 71

Re: Saving log files

Thanks Jagadish, that answered my question!

Fethon Naoum

Valued Guide
Posts: 2,174

Re: Saving log files

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.

Contributor
Posts: 71

Re: Saving log files

Thanks Peter, that's an elegant way of doing it.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 273 views
  • 3 likes
  • 3 in conversation