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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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