Using the PRINTTO Procedure in UNIX Environments

Important Note about the PRINTTO Procedure

Any time you use PROC PRINTTO to route output, you must close the output device before PROC PRINTTO will release the output or log and send it to the destination that you have specified. To close the output device, issue PROC PRINTTO without any parameters:
proc printto;
run;
Issuing PROC PRINTTO without any parameters closes the output device, generates output, and reroutes the log and procedure output to their default destinations. For a list of the default destinations, see Default Routings of the SAS Log and Output Files.
For more information, see PRINTTO Procedure: UNIX and PRINTTO Procedure in Base SAS Procedures Guide.

Using the LOG= and PRINT= Options

When you use the PRINTTO procedure with its LOG= and PRINT= options, you can route the SAS log or SAS procedure output to an external file or a fileref from any mode. Specify the external file or the fileref in the PROC PRINTTO statement. The following example routes procedure output to /u/myid/output/prog1:
proc printto print='/u/myid/output/prog1' new;
run;
The NEW option causes any existing information in the file to be cleared. If you omit the NEW option from the PROC PRINTTO statement, the SAS log or procedure output is appended to the existing file.
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 information and examples, see Assigning Filerefs to External Files or Devices with the FILENAME Statement.)

Routing Output to a Universal Printer

You can direct output directly to your Universal Printer by using the UPRINTER device type:
filename myoutput uprinter;
proc printto print=myoutput;
run;
Output will be sent to your default Universal Printer. This output will be in PostScript or PCL format.

Routing Output to a Printer

You can direct output directly to your system printer by using the PRINTER device type:
filename myoutput printer;
proc printto print=myoutput;
run;
Output will be sent to your default system printer or, if you have specified the SYSPRINT system option, to the printer specified with that option. This method will produce output in ASCII format.

Piping Output to a UNIX Command

You can also use the PIPE device type to send output to a UNIX command. When you specify the print command, you might also want to specify a destination for any error messages that are produced by the print command. Enclose the UNIX command in either single or double quotation marks. The following example associates the fileref MyOutput with the print command lp, which will send output to the printer named myljet:
filename myoutput pipe 'lp -dmyljet';
proc printto print=myoutput;
run;
You can send the SAS log to the same printer by using the LOG= option:
filename mylog pipe 'lp -dmyljet';
proc printto log=mylog;
run;
The log and procedure output continue to be routed to the designated external file until another PROC PRINTTO statement reroutes them.

Routing Output to a Terminal

In batch mode, you can direct output to a terminal by associating a fileref with a terminal and then using PROC PRINTTO to send output to that fileref. In the FILENAME statement, specify the TERMINAL device-type and the special file associated with the terminal. For example, the following statements send the SAS log to the terminal that is associated with the /dev/tty3 special file:
filename term terminal '/dev/tty3';
proc printto log=term;
run;