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.
Use the ALTLOG= system option, to generate a copy of the log.
Use the ALTLOG= system option, to generate a copy of the log.
Excellent, thanks!
Btw, is this alternate log file going to be appended? I don't want it to be.
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.
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
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;
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.
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.
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
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
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.
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;
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" 😉
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.