Home › Forums › Main Forums › SAS Forum › Save SAS Log to a File
-
Proc Printto
Proc Printto changes the default destination of the SAS LOG or the SAS procedure list output. By default, SAS log file is automatically written to a file named “filename.LOG”. SAS procedure output is written to filename .LST. Where filename is the name of your SAS job.For example, if your SYSIN file is AAA.sas, the procedure output file is named AAA.LST, and the log file is named MYPROG.LOG. However, you can change these default filenames and send your output to any file that you choose.
Filename AAA "C:\users\project_1\AAA.txt";
Proc printto LOG=LOG/AAA; ***LOG is default destination.
Proc printto print=Print/AAA New; *** Print is default.New, empty the previous content.
Proc printto; Run; *Reset SAS to write to the default destinations.In batch SAS sessions, the SAS procedure output and the SAS log are written by default to files named filename .LST and filename .LOG, respectively, where filename is the name of your SAS job.
For example, if your SYSIN file is MYPROG.SAS, the procedure output file is named MYPROG.LST, and the log file is named MYPROG.LOG. However, you can override these default filenames and
send your output to any file that you choose.For example, suppose that your job contains the following statements, which assign the fileref MYOUTPUT to the file C:\SAS\FIRST.TXT. Then the PROC PRINTTO statement tells SAS to send any upcoming SAS procedure output to the file that is associated with MYOUTPUT.
filename myoutput 'c:\sas\first.txt';
proc printto print=myoutput;
run;data uspres;
input pres $ party $ number;
datalines;
Adams F 2
;
run;
proc print; run;Any PROC or DATA statements that follow these statements and that generate output send their output to the C:\SAS\FIRST.TXT file, not to the default procedure output file. If you want to return to the default file, issue an empty PROC PRINTTO statement like the following example:
proc printto;
run;
data uspres2;
input pres $ party $ number;
datalines;
Lincoln R 16
Grant R 18
;
run;
proc print; run;Issuing these statements redirects the SAS procedure output to the default destination (filename.LST). In this way, you can send the output and log from different parts of the same SAS job to different files.
If you want to send the SAS log to a specific file, use the LOG= option instead of the PRINT= option in the PROC PRINTTO statement. For more information about the PRINTTO procedure, see PRINTTO Procedure: Windows and Base SAS Procedures Guide.
Note: When you use the PRINTTO procedure to route SAS procedure output or the SAS log, the Status window does not reflect any rerouting of batch output but indicates that it is routing the procedure output file and log to filename.LST and filename.LOG.
Log in to reply.