Hi,
Can I get the current path of the log file?
in other word:
proc printto log='c:\em\log1.log';
run;
%let log_path = command to get log path
You can change your code to get what you want:
%let log_path =c:\em;
proc printto log="&log_path.\log1.log";
run;
Pay attention - use double quotes instead single quotes.
@You wrote:
@Ditza1 wrote:
Some other code set the path or leave it the default value. I am looking
for a way to get it without knowing what happened there
As much as I know, there is no deault path for log.
You use FILENAME staetment to link symbolic name - the fileref - to a path,
or define the path directly in your step - as you have done with PROC PRINTTO in your post.
The PROC PRINTO LOG= defines where to save next sas code lines, until it reaches the:
PROC PRINTTO; RUN; - that closes the saved log file.
If there is a predefined path, it should be in a mcro variabe.
Online session log (window) is held in SAS utility catalog.
I'm not sure you have approach to it.
Just to be more clear, assuming the program is:
<code part 1>
proc printto log=<path and name.log>; run;
<code part 2>
proc pritto; run;
<code part 3>
the saved log will hold only part 2.
Check the macro-variable SYSPRINTTOLOG and the option LOG, depending on how the sas-session was started one of them is non-missing if the log is already written to a file.
Use %symexist() first to check if a variable exists; if it exists, inspect its contents.
But If It doesn't exist It brings me back to the problem of how to get log path
SYSPRINTTOLOG doesn't exist in neither of the stages of the following code
%put %symexist(SYSPRINTTOLOG);
filename logfile "Y:\log1.txt";
proc printto log= logfile new ; run;
%put %symexist(SYSPRINTTOLOG);
proc printto;run;
%put %symexist(SYSPRINTTOLOG);
You are right. I tested it in 9.4, both with a workspace server and display manager SAS, and in both cases SYSPRINTTOLOG is never set, although the log is successfully redirected.
This runs contrary to what is written in https://support.sas.com/resources/papers/proceedings15/SAS1575-2015.pdf, and in the relevant parts of the SAS documentation:
Strange. New session started with eg 7.12 on sas 9.4m3. Same result with display manager on the workspace server.
NOTE: PROZEDUR PRINTTO used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
25
26 %put &=SYSVLONG;
SYSVLONG=9.04.01M3P062415
27 %put &=SYSPRINTTOLOG;
SYSPRINTTOLOG="############\extlog.log"
28
29 proc printto;run;
This is what you need:
%LET LOG = %SYSFUNC(getoption(LOG));
I tried this but I get zero in all LOG macro variables:
filename logfile "C:\log1.txt";
proc printto log= logfile new ; run;
%LET LOG1 = %SYSFUNC(getoption(LOG));
proc printto;run;
%LET LOG2 = %SYSFUNC(getoption(LOG));
%put &LOG0;
%put &LOG1;
%put &LOG2;
my version is older then yours
SYSVLONG4=9.04.01M1P12042013
So I guess it works only in the newer versions
( And we have in my company older versions of sas)
Any other Ideas of getting log path without using
SYSPRINTTOLOG
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: