BookmarkSubscribeRSS Feed
Ditza1
Obsidian | Level 7

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

 

24 REPLIES 24
Shmuel
Garnet | Level 18

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.

Ditza1
Obsidian | Level 7
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
Shmuel
Garnet | Level 18

@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.

Shmuel
Garnet | Level 18

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.   

Ditza1
Obsidian | Level 7
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
andreas_lds
Jade | Level 19

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.

Ditza1
Obsidian | Level 7
This seems really what I was looking for, but I am getting
WARNING: Apparent symbolic reference SYSPRINTTOLOG not resolved.
Ditza1
Obsidian | Level 7

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);
andreas_lds
Jade | Level 19

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;
PSNn
Obsidian | Level 7

This is what you need:

 

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

 

Ditza1
Obsidian | Level 7

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;
Ditza1
Obsidian | Level 7

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

 

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 24 replies
  • 5301 views
  • 4 likes
  • 5 in conversation