When you run a program in SAS, you should always check the log to see if the program ran successfully. The usual approach is to check directly in your SAS editor. However, for different purposes, it may be beneficial to output the log to an external text file. Many ETL jobs save logs for documentation purposes. Many ETL setups export logs and read them into browser-based formats to visually assess the possible errors and warnings in the log. This post demonstrates how to use PROC PRINTTO to output the SAS log to an external file in your system.


There are several ways to export the log to an external file in SAS. However, I think the easiest and most straightforward is to use PROC PRINTTO. Simply specify the path and file name in the LOG= Option of the procedure. To direct it back to the editor again, simply specify a PROC PRINTTO step without options.

proc printto log="c:\MyLog.txt";
data MyData;
   do i=1 to 100;
proc printto;

Be aware that different circumstances require different file extensions. You will see examples where .log and .tmp are specified instead of .txt. The last time, I was stunned by the different purposes of the technique was reading the post, Kuhfeld’s Template Modification Technique (TMT), dedicated to the great Warren Kuhfeld. An ODS Graphics guru, who retired from SAS in 2018.


In this post, we have seen how to export the SAS log to an external text file. The technique is used for various purposes. I use the technique myself in the blog post Track Performance in SAS with the LOGPARSE Macro. Also, I demonstrate how to print the log both to an external text file and the log window in the post Write SAS log to text file and log window.

You can download the entire code from this example here.