Hi,
If I have a batch SAS job running in Windows, is there any way I can find out what the current path/name is of the log file it is generating?
I need to pass that to a log analyzer that I call at the end of the job.
Thanks!
--Ben
Hi @BenConner,
From within the running batch job you can retrieve the value of the LOG system option, i.e.,
%sysfunc(getoption(log))
will evaluate to the path of the log file. This would, however, not reflect redirections of the log via PROC PRINTTO calls in the program, if any. But if you wrote a PROC PRINTTO step, you would likely know the path anyway.
How are you running the batch job?
The command line used should allow you to set the output destination of the LOG or setting the Log options in the configuration file use or using proc printto
For example of a command line:
"C:\Program Files\SASHome\SASFoundation\9.4\Sas.exe"-SYSIN c:\job1.bat -NOSPLASH -ICON -PRINT c:\job1.lst –LOG c:\job1.log
.The -Log sets the location of the log file to c:\job1.log
Hi @BenConner,
From within the running batch job you can retrieve the value of the LOG system option, i.e.,
%sysfunc(getoption(log))
will evaluate to the path of the log file. This would, however, not reflect redirections of the log via PROC PRINTTO calls in the program, if any. But if you wrote a PROC PRINTTO step, you would likely know the path anyway.
Perfect. That's exactly what I was looking for. Rather than the %sysfunc, I just used a simple data step to test with but I think sysfunc would work better in the actual application.
Thanks much!
--Ben
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.