Previous Page | Next Page

Directing SAS Log and SAS Procedure Output

Directing Output to External Files with System Options


Overview of Directing Output to External Files with System Options

You can use SAS system options to change the destination of the SAS log and procedure output. The options that you use depend on which of the following tasks you want to accomplish:

Specify the system options in any of the following ways:

See Specifying or Changing System Option Settings for more information about specifying SAS system options.


Directing Output to an External File at SAS Invocation

Use the LOG= and PRINT= system options to change the destination of your SAS log or procedure output. The log and procedure output are then not directed to their default destinations.

When you invoke SAS, use the LOG= and PRINT= options to specify the ddnames or physical filenames of the output data sets. See LOG= System Option: z/OS and PRINT= System Option: z/OS for option syntax and other host-specific details.

SAS automatically allocates a file when a system option is specified with a physical filename. The following example illustrates a SAS invocation in noninteractive mode using the SAS CLIST with internal allocation of output files:

sas options ('log=myid.output.logdata
   print=myid.output.ptrdata')
   input('''myid.sas.program''')

This example illustrates the same SAS invocation using external allocation:

alloc fi(logout) da('myid.output.logdata') old
alloc fi(printout) da('myid.output.prtdata') old
sas options('log=logout print=printout')input('''myid.sas.program''')

This example illustrates a SAS invocation in batch mode, using a JCL EXEC statement and internal allocation of output files:

//SASSTEP EXEC SAS,
//   OPTIONS='LOG=<file> PRINT=<file> ALTLOG=<file>'

This example illustrates the same SAS invocation with external allocation:

//SASSTEP  EXEC SAS,
//              OPTIONS='LOG=LOGOUT PRINT=PRINTOUT'
//LOGOUT   DD   DSN=MYID.OUTPUT.LOGDATA,DISP=OLD
//PRINTOUT DD   DSN=MYID.OUTPUT.PRTDATA,DISP=OLD
//SYSIN    DD   DSN=MYID.SAS.PROGRAM,DISP=SHR

The LOG= and PRINT= system options are normally used in batch, noninteractive, and interactive line modes. These options have no effect in the windowing environment, which still displays SAS log and procedure output data in the Log and Output windows. To capture and print data in the Log and Output windows, use the ALTLOG= and ALTPRINT= options, as described in the next section.

See ALTLOG= System Option: z/OS and ALTPRINT= System Option: z/OS for option syntax and other host-specific details.


Copying Output to an External File

Use the ALTLOG= and ALTPRINT= system options to send a copy of your SAS log or procedure output to an external file. After specifying ALTLOG= and ALTPRINT=, the log and procedure output is still displayed in the Log and Output windows as usual. The log and procedure output are still directed to their default SAS file destinations or to the nondefault destinations specified by the LOG= and PRINT= system options, as described in the preceding section.

When you invoke SAS, use the ALTLOG= and ALTPRINT= options as shown to specify the ddnames or physical filenames of the allocated data sets:

sas options('altprint=myid.output.prtdata
   altlog=myid.output.logdata')

See the previous section for complete examples of SAS invocations in various modes.


Directing Output to External Files Using the Configuration File

This example illustrates how to direct output to external files using the SAS configuration file:

log=myid.output.logdata
* logout ddname must be allocated
log=logout

print=myid.output.prtdata
* printout ddname must be allocated
print=printout

altlog=myid.output.altlog
* altlogx ddname must be allocated
altlog=altlogx

Previous Page | Next Page | Top of Page