HomeHow To

Save SAS log to an external file : Proc Printto in SAS1 min read

Like Tweet Pin it Share Share Email

PROC PRINTTO procedure is used to redirect log output and procedure output to files or printers. To save the output in an external file, specify the external file or the fileref in the PROC PRINTTO statement.


PROC PRINTTO <options>;

Options in Proc Printto

LABEL= It provides a description for a SAS log or procedure output stored in a SAS catalog entry.

LOG= The name of the external file where you want to save the log.

NEW It replaces the file instead of appending to it. If you do not specify the New option, the Log will be appended to the existing file whenever the code runs.

PRINT=  It is used for print file specification to procedure output to a permanent external file or SAS catalog entry or printer.

UNIT=nn routes the output to the file identified by the fileref.

A simple example of Proc Printto Procedure

proc printto log="/home/9to5sas/saslogs/log1.txt";

data class;
	set sashelp.cars;
	where origin="Asia";

proc printto;

If you plan to specify the same destination several times in your SAS program, you can assign a fileref to the file using a FILENAME statement. For example, you can use the PRINTER device type to send the output directly to your system printer:

filename myoutput printer;
proc printto print=myoutput;

After PROC PRINTTO executes, all procedure output is sent to the alternate location until you execute another PROC PRINTTO statement or until your program or session ends. The following statements – PROC PRINTTO statement with no options)redirect the SAS log and procedure output to the original default destinations:

proc printto;

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.