Previous Page | Next Page

Printing with SAS

Configuring Universal Printing with Programming Statements


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 Options That 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.

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.  [cautionend]

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.

Creating a Data Set That Defines Multiple 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 $&;
Myprinter             PostScript Level 1   PRINTER   printer1
Laserjet              PCL 5 Printer        PIPE      lp -dprinter5
Color LaserJet        PostScript Level 2   PIPE      lp -dprinter2

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;

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.  [cautionend]

Installing a Printer Definition for Multiple Users

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";

proc prtdef data=tek780 usesashelp;

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.  [cautionend]

Adding, Modifying, and Deleting Printer Definitions

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 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 $ &;
add  Color PostScript   PostScript Level 2 (Color)       DISK
mod  LaserJet 5         PCL 5                            DISK    sasprt.pcl
del  Gray PostScript    PostScript Level 2 (Gray Scale)  DISK
del  test               PostScript Level 2 (Color)       DISK
add  ColorPS            PostScript Level 2 (Color)       DISK

proc prtdef data=printers list usesashelp;

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.   [cautionend]

Creating a Ghostview Previewer Definition for Previewing PostScript Output

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.

data gsview;
   name = "Ghostview";
   desc = "Print Preview with Ghostview";
   model= "PostScript Level 2 (Color)";
   viewer = 'ghostview %s';
   device = "dummy";
   dest = " ";
proc prtdef data=gsview list replace;

Exporting and Backing Up Printer Definitions

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.

 [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;

For more information, see the PRTEXP procedure in Base SAS Procedures Guide.

Sample Values for the Device Type, Destination, and Host Options Fields

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.

Previous Page | Next Page | Top of Page