|SAS Companion for UNIX Environments|
In the SAS windowing environment, you can use the PRTFILE, PRINT, and FILE commands to send the contents of the active window to an output device. The PRINT command sends the contents of the active window to either your default printer or to the location you specify with the PRTFILE command. With the PRTFILE, you can specify either a filename or a fileref. The FILE command sends the contents of the active window to the filename or fileref that you specify. With the FILENAME statement, you can create filerefs that point to printers, plotters, or external files or filerefs that pipe your output to a UNIX command. You can use the PRINT and PRTFILE commands with forms or with host printing.
|Using the PRINT Command with Forms|
Use the PRINT command to route the contents of a window to your default printer. This is the easiest method of printing output. For example, issue the PRINT command from the command line of your OUTPUT window to send the contents of that window to your default printer.
To route the contents of a window to a printer that is not your default printer, you can use select a different form through the pull-down menu:
|File||Print Utilities||Set Form Name...|
Note: Multiple forms can be specified for the same printer.
Select a form that uses a printer other than your default printer.
You can also select a different form by specifying the FORM= option with the PRINT command. For example, to copy output to a printer destination that is described in a form named MYOUTPUT, you enter the following command-line command:
For more information on forms, see Defining Forms.
|Using PRTFILE and PRINT with a Fileref|
You can also use the PRTFILE command, followed by the PRINT command, to print the contents of windows. This method enables you to override some of the defaults that are established by the FORM subsystem, such as the destination.
PRTFILE establishes the destination, and PRINT sends the contents of the window to that destination. If you do not specify a destination with the PRTFILE command, PRINT automatically sends the window contents to your default printer.
If you want to send output directly to a printer, you must first submit the FILENAME statement to assign a fileref to a PRINTER, XPRINTER, or PIPE device. For example, to print the contents of your OUTPUT window:
For example, the following statement associates MYRPT with the system printer named BLDGA2 and specifies two copies of every printout:
filename myrpt printer 'bldga2 -n2';(See the documentation for your print command for information about other options that you can specify.)
The following statement allows you to print output using
lp command on the printer
filename ascout pipe 'lp -dmyljet';
The following statement sends output to the
lp command and redirects any error messages produced
by this command to the
lperror file in your home directory:
filename myrpt pipe 'lp 2>$HOME/lperror';
Note: Redirecting standard error is allowed only in
the Bourne and Korn shells.
The following statement associates MYRPT with your default host printer device:
filename myrpt xprinter;MYRPT can be defined as an external file or as a Postscript (or PCL) printer. You cannot specify options with the XPRINTER device, and you can open only one XPRINTER device at a time during a SAS session.
If you frequently use the same print command and destination, you can add the appropriate FILENAME statement to your autoexec file. See Customizing Your SAS Session for more information.
Ain the requestor window to append the window contents to the destination file.
Note: If you are using host
printing to send output to a file, the file will always be replaced; APPEND
is not valid for an XPRINTER device.
filename myrpt clear;
To return to forms-based printing, issue the PRTFILE CLEAR command.
|Using the FILE Command|
You can use the FILE command to copy the contents of many different windows
to external files. Issue the FILE command on the command line of the window
whose contents you want to copy. For example, to copy the contents of the
LOG window to
issue the following command on the command line of the LOG window:
If the file does not exist, SAS creates it. If the file already exists, a requestor window asks you whether you want to replace it or to append data to the existing data.
If you have already associated a fileref with your external file, you can use the fileref instead of the filename:
Note: If you use the FILE command to save your output, carriage-control information is not saved (that is, page breaks are removed from the output). You may want to use the PRINT command with the FILE option instead:
|PRINT FILE=fileref | 'pathname'|
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.