Chris,

This is very handy, thank you, and it set me to thinking, and I realised that it may be worth my trying a similar approach for log files.

In some programs I set file destinations for log and listing output, using proc printto, and then close these destinations at the end of the program.

So far, so good, ..., but this becomes messy when I %include files that use the same idea and proc printto statements become nested.

Using an approach similar to this one, I can check sashelp.vextfl for log and listing files (this would require a naming convention for these files) before redirecting output. If there was an active destinations I could restore log and listing output to these instead of using the terminating proc printto; run;.

Further, I could add a helpful note to tell the reader of the parent log where to find the missing middle chunk of logging.

Finally, by using a push/pop stack, one should be able to accommodate multiple levels of nesting.

I think I'm going to be busy tomorrow, thanks!

Rob