Printing with SAS |
Introduction |
Universal Printing windows give you control over most printing functions through a graphical user interface. (You can also write a program that uses various SAS language elements to configure your printing environment and to control print jobs.)
System Options That Control Universal Printing |
Universal Printing can be configured in batch mode and interactive mode by setting system option values within an OPTIONS statement. The following system options control Universal Printing.
System Option | Description |
---|---|
BINDING= | Specifies the binding edge for the printer. |
BOTTOMMARGIN= | Specifies the size of the margin at the bottom of the page for printing. |
COLLATE | Specifies the collation of multiple copies for output for the printer. |
COLORPRINTING | Specifies color printing, if it is supported. |
COPIES = | Specifies the number of copies to make when printing. |
DUPLEX | Specifies double-sided printing, if it is supported. |
LEFTMARGIN= | Specifies the size of the margin on the left side of the page. |
ORIENTATION= | Specifies the paper orientation to use (either portrait or landscape). |
PAPERDEST= | Specifies the bin or output paper tray to receive printed output. |
PAPERSIZE= | Specifies the paper size to use when printing. |
PAPERSOURCE= | Specifies the input paper tray to use for printing. |
PAPERTYPE= | Specifies the type of paper to use for printing. |
PRINTERPATH= | Specifies a printer for Universal Printing print jobs (see Note). |
RIGHTMARGIN= | Specifies the size of the margin on the right side of the page. |
SYSPRINTFONT= | Specifies the default font to use when printing. |
TOPMARGIN= | Specifies the size of the margin at the top of the page. |
Note: The PRINTERPATH= system option specifies which printer will be used.
If the PRINTERPATH= system option is blank, then the default printer will be used.
If the PRINTERPATH= system option is not blank, then Universal Printing will be used.
In the Windows environment, the default printer is the current Windows system printer or the printer specified by the SYSPRINT system option; therefore, Universal Printing is not used. In all other operating environments, Universal Printing is used and the default printer is PostScript Level 1. To change this printer, use either the SYSPRINT system option or the DMPRINTSETUP command to open the Print Setup window.
Defining Printers for Batch Mode |
Printer definitions can be created for an individual, or for all SAS users at a site, by using the PRTDEF procedure. The PRTDEF procedure can be used to do many of the same printer management activities that you can also do with the Universal Printing windows. The PRTDEF procedure is especially useful if you use SAS in batch mode, where the Universal Printing windows are unavailable.
Only system administrators or others who have write permission to the SASHELP library can use the PRTDEF procedure to create printer definitions for all SAS users at a site.
To define one or more printers with the PRTDEF procedure, you first create a SAS data set that contains variables corresponding to printer attributes. The PRTDEF procedure reads the data set and converts the variable attributes into one or more printer definitions in the SAS registry.
See Base SAS Procedures Guide for more information about the PRTDEF procedure.
Defining New Printers and Previewers with the PRTDEF Procedure |
These examples show you how to use the PRTDEF procedure to define new printers and to manage your installed printers and previewers.
After a program statement containing the PRTDEF procedure runs successfully, the printers or previewers that have been defined will be displayed in the Print Setup window. A complete set of all available printers and previewers will be displayed in the Printer name list. Printer definitions can also be seen in the Registry Editor window under CORE\\PRINTING\\PRINTERS.
When you create a data set to use with the PRTDEF procedure to define a printer, you must specify the name, model, device and, destination variables.
See the PRTDEF procedure in Base SAS Procedures Guide for the names of the optional variables that you can also use.
The following code creates a data set to use with the PRTDEF procedure:
data printers; input name $& model $& device $& dest $&; datalines; Myprinter PostScript Level 1 PRINTER printer1 Laserjet PCL 5 Printer PIPE lp -dprinter5 Color LaserJet PostScript Level 2 PIPE lp -dprinter2 ; run;
After you create the data set containing the variables, you run a SAS program that contains the PRTDEF procedure. The PRTDEF procedure defines the printers that are named in the data set by creating the appropriate entries in the SAS registry.
proc prtdef data=printers usesashelp; run;
Note: The USESASHELP option specifies that the printer definitions are to be placed in the SASHELP library, where they are available to all users. If the USESASHELP option is not specified, then the printer definitions are placed in the current SASUSER library, where they are available to the local user only, and the printers that are defined will be available only in the local SASUSER directory. However, to use the USESASHELP option, you must have permission to write to the SASHELP catalog.
This example creates a Tektronix Phaser 780 printer definition with a Ghostview print previewer in the SASHELP registry. The bottom margin is set to two centimeters, the font size to 14 point, and the paper size to A4.
data tek780; name = "Tek780"; desc = "Test Lab Phaser 780P"; model = "Tek Phaser 780 Plus"; device = "PRINTER"; dest = "testlab3"; preview = "Ghostview"; units = "cm"; bottom = 2; fontsize = 14; papersiz = "ISO A4"; run; proc prtdef data=tek780 usesashelp; run;
Note: You must specify a preview command either in the Preview Definition Wizard (Printer Properties Window Displaying Advanced Tab) or on the Advanced tab of the Printer Properties window (Previewer Definition Window to Enter Command to Open Previewer Application) or by using the PRDEF procedure.
This example uses the PRINTERS data set to add, modify, and delete printer definitions. See the PRTDEF procedure in Base SAS Procedures Guide for more variables that you can use to define a printer. The following list describes the variables used in the example:
The MODEL variable specifies the printer prototype to use when defining this printer.
The DEVICE variable specifies the type of I/O device to use when sending output to the printer.
The DEST variable specifies the output destination for the printer.
The OPCODE variable specifies what action (Add, Delete, or Modify) to perform on the printer definition.
The first Add operation creates a new printer definition for Color PostScript in the registry and the second Add operation creates a new printer definition for ColorPS in the registry.
The Mod operation modifies the existing printer definition for LaserJet 5 in the registry.
The Del operation deletes the printer definitions for printers named "Gray PostScript" and "test" from the registry.
The following example creates a printer definition in the SASHELP library. Because the definition is in SASHELP, the definition becomes available to all users. Special system administration privileges are required to write to the SASHELP library. An individual user can create a personal printer definition by specifying the SASUSER library instead.
data printers; length name $ 80 model $ 80 device $ 8 dest $ 80 opcode $ 3; input opcode $ & name $ & model $ & device $ & dest $ &; datalines; add Color PostScript PostScript Level 2 (Color) DISK sasprt.ps mod LaserJet 5 PCL 5 DISK sasprt.pcl del Gray PostScript PostScript Level 2 (Gray Scale) DISK sasprt.ps del test PostScript Level 2 (Color) DISK sasprt.ps add ColorPS PostScript Level 2 (Color) DISK sasprt.ps ; proc prtdef data=printers list usesashelp; run;
Note: If the end user modifies and saves new attributes for an administrator-defined printer in the SASHELP library, the printer will become a user-defined printer in the SASUSER library. Values that are specified by the user will override the values that were set by the administrator. If the user-defined printer definition is deleted, the administrator-defined printer will reappear.
This example creates the GSVIEW data set. The variables in the GSVIEW data set have values that the PRTDEF procedure uses to produce the print previewer definition in the SAS registry.
The NAME variable specifies the printer name that will be associated with the rest of the attributes in the printer definition data record.
The DESC variable specifies the description of the printer.
The MODEL variable specifies the printer prototype to use when defining this printer.
The VIEWER variable specifies the host system commands for print preview.
Note: The ghostview %s command needs to be the fully qualified command if it is not in the machine's command path.
Note: You must specify a preview command either in the Preview Definition Wizard (Printer Properties Window Displaying Advanced Tab) or on the Advanced tab of the Printer Properties window (Previewer Definition Window to Enter Command to Open Previewer Application).
The DEVICE variable should always be DUMMY.
DEST should be blank to specify that output is not returned.
data gsview; name = "Ghostview"; desc = "Print Preview with Ghostview"; model= "PostScript Level 2 (Color)"; viewer = 'ghostview %s'; device = "dummy"; dest = " "; run; proc prtdef data=gsview list replace; run;
The PRTEXP procedure enables you to back up your printer definitions as a SAS data set that can be restored with the PRTDEF procedure.
The PRTEXP procedure has the following syntax.
PROC PRTEXP [USESASHELP] [OUT=dataset] [SELECT | EXCLUDE] printer_1 printer_2 ... printer_n;
The following example shows how to back up four printer definitions (named PDF, postscript, PCL5, and PCL5c) using the PRTDEF procedure.
proc prtexp out=printers; select PDF postscript PCL5 PCL5c; run;
For more information, see the PRTEXP procedure in Base SAS Procedures Guide.
The following list provides examples of the printer values for device type, destination and host options. Because these values can be dependent on each other, and the values can vary by operating environment, several examples are shown. You might want to refer to this list when you are installing or modifying a printer or when you change the destination of your output.
Device Type: Printer
z/OS
Device type: Printer
Destination: (leave blank)
Host options: sysout=class-value dest=printer-name
UNIX and Windows
Device type: Printer
Destination: printer name
Host options: (leave blank)
OpenVMS
Device type: Printer
Destination: printer name
Host options: passall=yes queue=printer-name
Device Type: Pipe
Note: A sample command to send output to an lp-defined printer queue on a UNIX host is lp -ddest
UNIX
Device Type: Pipe
Destination: command
Host options: (leave blank)
Device Type: FTP
Note: An example of a nodename is pepper.unx
z/OS
Device type: FTP
Destination: ftp.out
Host options: host='nodename' recfm=vb prompt
Device type: Printer
Destination: printer name
Host options: (leave blank)
Windows
Device type: FTP
Destination: ftp.out
Host options: host='nodename' prompt
UNIX and OpenVMS
Device type: FTP
Destination: host='nodename' prompt
Host options: (leave blank)
Device Type: Socket
Note: An example of an lp destination queue is lp286nc0.prt:9100
UNIX and OpenVMS
Device type: Socket
Destination: destination-queue
Host options: (leave blank)
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.