Nov 2, 2012

Redirecting your SAS LOG and OUTPUT to external files

The PRINTTO procedure defines destinations for SAS procedure output and for the SAS log. By default, SAS procedure output and the SAS log are routed to the default procedure output file and the default SAS log file for your method of operation. See Default Destinations for SAS Log and Procedure Output. You can store the SAS log or procedure output in an external file or in a SAS catalog entry. With additional programming, you can use SAS output as input data within the same job.
PROC PRINTTO

To do thisUse this option
provide a description for a SAS log or procedure output stored in a SAS catalog entryLABEL=
route the SAS log to a permanent external file or SAS catalog entryLOG=
combine the SAS log and procedure output into a single fileLOG= and PRINT= with same destination
replace the file instead of appending to itNEW
route procedure output to a permanent external file or SAS catalog entry or printer.PRINT=
filename logf "C:\Documents and Settings\SASTechies\Desktop\log.txt";
 
proc printto log=logf new; /*redirecting the log to log.txt*/
   run;
 
  data numbers;
   input x y z;
   datalines;
 14.2   25.2   96.8
 10.8   51.6   96.8
  9.5   34.2  138.2
  8.8   27.6   83.2
 11.5   49.4  287.0
  6.3   42.0  170.7
;
 
proc printto print='C:\Documents and Settings\SASTechies\Desktop\output.txt' new; /*redirecting the output to output.txt*/
run;
 
proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;
 
/* You can also combine the SAS log and procedure output into the same/single file.
   Note: that you should NOT have the NEW option in this case or else it would delete the contents of the files everytime there is a new line in the log/output
*/
 
filename combined "C:\Documents and Settings\SASTechies\Desktop\combined.txt";
 
proc printto print=combined; /*redirecting the output to combined.txt*/
run;
 
proc printto log=combined; /*redirecting the output to combined.txt*/
run;
 
proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;
 
proc printto;run; /* Re-routing the log and output destinations to the default locations */