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 it 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"; run; data class; set sashelp.cars; where origin="Asia"; run; proc printto; run;
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; run;
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; run;