BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
evp000
Quartz | Level 8

Hi,

 

I want to keep my usual log as is AND output a part of it to another destination (text file) as well.  Any suggestions, without running the code over again using a different proc prinnto destination? My normal log is saved so I could also get the info from there but it would be a fair amount of manipulation just to get the bit I need. 

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Use the ALTLOG= system option, to generate a copy of the log.

View solution in original post

13 REPLIES 13
Astounding
PROC Star

Use the ALTLOG= system option, to generate a copy of the log.

evp000
Quartz | Level 8

Excellent, thanks!

evp000
Quartz | Level 8

Btw, is this alternate log file going to be appended?  I don't want it to be. 

Shmuel
Garnet | Level 18

Are you running you program in batch mode or online?

 

If you run as batch add to the SAS execute line the ALTLOG= optionn and define the path and log name.

I think it will include also the part written by PROC PRINTTO, that you mentioned.

zekeT_sasaholic
Quartz | Level 8

Ok.

my understanding is that log_a is ok at 100 pct of log or rows has all output.

but the goal is log_b has only the section you are interested in.

if that is correct...

 

its possible to use "proc printto log="../newfolder/subseta_of_log.log  new;"

the key would be to strategically place this in your code and then -close- that log with a complementary "proc printto log=log; run;" once the section you need is over.

 

note: that this will split up your log into two files (two logs).

you still need ONE master log (if thats what you want)

you can do this by specifiying in command line executable or via config the altlog= option mentioned in the other suggestion.

while you would end up with 3 distinct logs.  1 would be the entire log (from altlog) the other two specified from your use of printto.

 

hth

 

zeke torres

www.wscug.com

 

 

 

so your code would read:

/*** top of code nothing run yet***/

 

proc printto log=log; run; *** this is redundant;

 

data work.test /* ... (step 1)*/;

*other code;

run;

 

proc print data=work.test (obs=30);

run;

 

/** all that will go to regular log **/

/** now the subset log **/

proc printto log="../newfolder/subseta_of_log.log  new; run;

 

proc /** something else ***/

run;

 

proc print /** something else **/

run;

 

/** now that you are done - set log back to default **/

proc printto log=log; run;

 

 

/*** rest of your code ***/

 

endsas;

evp000
Quartz | Level 8

Yes, you understood my question correctly. It seems a lot easier to just have the normal log output (so no changes to current proc printto's), then use

 

* beginning of program *;

 

option altlog "destination.log";

 

* code that generates the log I want an extra copy of *;

 

option noaltlog;

 

* end of program *; 

 

 

I'm testing this right now.  

evp000
Quartz | Level 8

Looks like I can't pop that into the middle of my program:

WARNING 11-12: SAS option ALTLOG is valid only at startup of the SAS System or startup of a SAS process. The SAS option is ignored.

zekeT_sasaholic
Quartz | Level 8

that message is correct.  

SAS options have orders of priority or availability to change based on where its being executed.

The use of this altlog as an "in code" option is limited.

Altlog is something you might need to do at config or command line.

 

you would need to configure your sas config file.

for example: im on linux and have a local .sasv9.cfg file.

in that file i can specify my altlog

 

in fact in our location we are currently monitoring some parts of our usage.

we have a global config option with an altlog.

 

so i know this can work - but your going to have issues if your trying to set that option in the wrong place.

 

if you are running EG - you can still configure your config file - but you would need to find it and create a copy.

 

hth

 

zekeT_sasaholic
Quartz | Level 8

ah - i think i see what you've tried.

 

again - options "in code" can only be set once.

 

my original suggestion still stands.

 

within your code: use the proc printto - this will allow you to split up your log to the parts you want to keep and part to ignore.

then outside of your code - use altlog - using the config or command prompt - this will enable you to keep an entire log.

 

hth

evp000
Quartz | Level 8

Thanks but it looks like the easiest thing in this case is to just get the info I need from the original log.  The logs are saved in a standard process for all the programs and I don't want to mess with it. 

Tom
Super User Tom
Super User

If you are confident that your job will not die in the middle part then you could copy the log back to the main log. It will look a little strange,but the information will be there.

 

So first redirect to a file

proc printto log='My new log file.log' new; run;

Then run the steps that you want to have the log information written to that file.  THen close it and copy it back into the real log.

proc printto log=log; run;

data _null_;
  if _n_=1 or eof then put '****** COPY OF LOG LINES WRITTEN TO SEPARATE FILE ****;
  infile 'My new log file.log' end=eof;
  input;
  put _infile_;
run;
evp000
Quartz | Level 8

Thanks, interesting to know but too much trouble in this case I think. Or maybe I'm too lazy.  My first thought was "I swear these people are conspiring to make my life more difficult" 😉

Ksharp
Super User
Why not use OS command COPY or function copy() .

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

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
  • 13 replies
  • 5608 views
  • 7 likes
  • 6 in conversation