You
can use the PRINTTO procedure to redirect SAS procedure output from
the HTML destination to an alternate location. These locations are:
-
-
-
a dummy file, which serves to suppress
the output
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.
Note: If you used the Output Delivery
System (ODS) to close the HTML destination, then PROC PRINTTO does
not receive any output to redirect. However, the procedure results
still go to the destination that you specified with ODS.
You use the PRINT= option in the PROC
PRINTTO statement to specify the name of the file or SAS catalog that
will contain the procedure output. If you specify a file, then either
use the complete name of the file in quotation marks or use a fileref
for the file.
(See Using External Files in Your SAS Job for more information
about filerefs and filenames.) You can also specify
the NEW option in the PROC PRINTTO statement so that SAS replaces
the previous contents of the output file. Otherwise, SAS appends the
output to any output that is currently in the file.
To route output to an
alternate file, insert a PROC PRINTTO step in the program before the
PROC step that generates the procedure output. The following program
routes the output from PROC PRINT to an external file:
proc printto print=
'alternate-output-file' new;
run;
proc print data=test_scores;
title 'Test Scores for Entering University Classes';
run;
proc printto;
run;
After the PROC PRINT step executes,
alternate-output-file contains
the procedure output. The second PROC PRINTTO step redirects output
back to its default location.
The PRINTTO procedure
does not produce the output. Instead, it tells SAS to route the results
of all subsequent procedures until another PROC PRINTTO statement
executes. Therefore, the PROC PRINTTO statement must precede the procedure
whose output you want to route.
The figure below shows
how SAS uses PROC PRINTTO to route procedure output. You can also
use PROC PRINTTO multiple times in a program so that output from different
steps of a SAS job is stored in different files.