## Log Path

Occasional Contributor
Posts: 11

# Log Path

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

Posts: 1,683

## Re: 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.

Occasional Contributor
Posts: 11

## Re: Log Path

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
Posts: 1,683

## Re: Log Path

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.

Posts: 1,683

## Re: Log Path

[ Edited ]

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.

Occasional Contributor
Posts: 11

## Re: Log Path

I am not sure l used the right terms.

I wrote a macro that can be used in a lot of other macros. The macro
redirect the log to file and needs to redirect it back to where it was at
the end of the macro. So l am looking for a way to get the log path before
I change it, so i can redirect back at the end of the macro
Super Contributor
Posts: 411

## Re: Log Path

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.

Occasional Contributor
Posts: 11

## Re: Log Path

This seems really what I was looking for, but I am getting
WARNING: Apparent symbolic reference SYSPRINTTOLOG not resolved.
Super User
Posts: 8,589

## Re: Log Path

Use %symexist() first to check if a variable exists; if it exists, inspect its contents.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

## Re: Log Path

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);
Super User
Posts: 8,589

## Re: Log Path

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:

http://documentation.sas.com/?docsetId=proc&docsetTarget=p1hwvc03z4tqlkn1owzhzo8e7ulu.htm&docsetVers...

http://documentation.sas.com/?docsetId=proc&docsetTarget=p182p6h2jd0qr2n1hjoj0kp2q03a.htm&docsetVers...

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 411

## Re: Log Path

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;
Occasional Contributor
Posts: 14

## Re: Log Path

This is what you need:

%LET LOG = %SYSFUNC(getoption(LOG));

Occasional Contributor
Posts: 11

## Re: Log Path

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;
Occasional Contributor
Posts: 11

## Re: Log Path

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

Discussion stats
• 24 replies
• 320 views
• 3 likes
• 5 in conversation