PRINTTO Procedure

Example 1: Routing to External Files

Features:

PRINTTO statement without options

PRINTTO statement options::
LOG=
NEW
PRINT=

Details

This example uses PROC PRINTTO to route the log and procedure output to an external file and then reset both destinations to the default.

Program

options nodate pageno=1 linesize=80 pagesize=60 source;
proc printto log='log-file';
   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
;
ods listing;
proc printto print='output-file'
new;
run;
proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;
proc printto;
run;
ods listing close;

Program Description

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. PAGENO= specifies the starting page number. LINESIZE= specifies the output line length, and PAGESIZE= specifies the number of lines on an output page. The SOURCE option writes lines of source code to the default destination for the SAS log.
options nodate pageno=1 linesize=80 pagesize=60 source;
Route the SAS log to an external file. PROC PRINTTO uses the LOG= option to route the SAS log to an external file. By default, this log is appended to the current contents of log-file.
proc printto log='log-file';
   run;
Create the NUMBERS data set. The DATA step uses list input to create the NUMBERS data set.
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
;
Route the procedure output to an external file. PROC PRINTTO routes output to an external file. The LISTING destination must be open in order to route SAS output to an external file. Because NEW is specified, any output written to output-file will overwrite the file's current contents.
ods listing;
proc printto print='output-file'
new;
run;
Print the NUMBERS data set. The PROC PRINT output is written to the specified external file.
proc print data=numbers;
   title 'Listing of NUMBERS Data Set';
run;
Reset the SAS log and procedure output destinations to default.PROC PRINTTO routes subsequent logs and procedure output to their default destinations and closes both of the current files. Then, close the LISTING destination.
proc printto;
run;
ods listing close;

Log

Portion of Log Routed to the Default Destination

01   options nodate pageno=1 linesize=80 pagesize=60 source;
02
03   proc printto log='log-file';
04   run;

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
Portion of Log Routed to an External File

  NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

68   
69   data numbers;
70      input x y z;
71      datalines;

NOTE: The data set WORK.NUMBERS has 6 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

78   ;
79   ods listing;
80   proc printto
81   print='c:\em\print1.out'
82   new;
83   run;

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

84   
85   proc print data=numbers;
86      title 'Listing of NUMBERS Data Set';
87   run;

NOTE: There were 6 observations read from the data set WORK.NUMBERS.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.32 seconds
      cpu time            0.07 seconds
      

88   
89   proc printto;
90   run;
NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


91   ods listing close;

Output

Procedure Output Routed to an External File
Procedure Output Routed to an External File