BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PTD_SAS
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

you can try to use the procedure

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

run;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

you can try to use the procedure

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

run;

Thanks,

Jagadish

Thanks,
Jag
PTD_SAS
Obsidian | Level 7

Thanks Jagadish, that answered my question!

Fethon Naoum

Peter_C
Rhodochrosite | Level 12

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.

PTD_SAS
Obsidian | Level 7

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

SAS Innovate 2025: Register Now

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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