Examples: PRTDEF Procedure


Example 1: Defining Multiple Printer Definitions

Procedure features:

  • PROC PRTDEF statement options:

    • DATA=

    • USESASHELP

This example shows you how to set up various printers.

Program

Create the PRINTERS data set. The INPUT statement contains the names of the four required variables . Each data line contains the information that is needed to produce a single printer definition.

 data printers;  input name $ 1-14 model $ 16-42 device $ 46-53 dest $ 57-70;  datalines;  Myprinter      PostScript Level 1 (Color)    PRINTER   printer1  Laserjet       PCL 5                         PIPE      lp -dprinter5  Color LaserJet PostScript Level 2 (Color)    PIPE      lp -dprinter2  ; 

Specify the input data set that contains the printer attributes, create the printer definitions, and make the definitions available to all users. The DATA= option specifies PRINTERS as the input data set that contains the printer attributes.

PROC PRTDEF creates the printer definitions for the SAS registry, and the USESASHELP option specifies that the printer definitions will be available to all users.

 proc prtdef data=printers usesashelp;  run; 

Example 2: Creating a Ghostview Printer in SASUSER to Preview PostScript Printer Output in SASUSER

Procedure features:

  • PROC PRTDEF statement options:

    • DATA=

    • LIST

    • REPLACE

This example creates a Ghostview printer definition in the SASUSER library for previewing PostScript output.

Program

Create the GSVIEW data set, and specify the printer name, printer description, printer prototype, and commands to be used for print preview. The GSVIEW data set contains the variables whose values contain the information that is needed to produce the printer definitions.

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 to be used for print preview. GSVIEW must be installed on your system and the value for VIEWER must include the path to find it. You must enclose the value in single quotation marks because of the %s . If you use double quotation marks, SAS will assume that %s is a macro variable.

DEVICE and DEST are required variables, but no value is needed in this example. Therefore, a dummy or blank value should be assigned.

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

Specify the input data set that contains the printer attributes, create the printer definitions, write the printer definitions to the SAS log, and replace a printer definition in the SAS registry. The DATA= option specifies GSVIEW as the input data set that contains the printer attributes.

PROC PRTDEF creates the printer definitions.

The LIST option specifies that a list of printers that are created or replaced will be written to the SAS log.

The REPLACE option specifies that a printer definition will replace a printer definition in the registry if the name of the printer definition matches a name already in the registry. If the printer definition names do not match, then the new printer definition is added to the registry.

 proc prtdef data=gsview list replace;  run; 

Example 3: Creating a Single Printer Definition That Is Available to All Users

Procedure features:

  • PROC PRTDEF statement option:

    • DATA=

This example creates a definition for a Tektronix Phaser 780 printer with a Ghostview print previewer with the following specifications:

  • bottom margin set to 1 inch

  • font size set to 14 point

  • paper size set to A4.

Program

Create the TEK780 data set and supply appropriate information for the printer destination. The TEK780 data set contains the variables whose values contain the information that is needed to produce the printer definitions.

In the example, assignment statements are used to assign these variables.

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 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 PREVIEW variable specifies which printer will be used for print preview.

The UNITS variable specifies whether the margin variables are measured in centimeters or inches.

The BOTTOM variable specifies the default bottom margin in the units that are specified by the UNITS variable.

The FONTSIZE variable specifies the point size of the default font.

The PAPERSIZ variable specifies the default paper size.

 data tek780;     name = "Tek780";     desc = "Test Lab Phaser 780P";     model = "Tek Phaser 780 Plus";     device = "PRINTER";     dest = "testlab3";     preview = "Ghostview";     units = "cm";     bottom = 2.5;     fontsize = 14;     papersiz = "ISO A4";  run; 

Create the TEK780 printer definition. The DATA= option specifies TEK780 as the input data set.

 proc prtdef data=tek780;  run; 

Example 4: Adding, Modifying, and Deleting Printer Definitions

Procedure features:

  • PROC PRTDEF statement options:

    • DATA=

    • LIST

This example

  • adds two printer definitions

  • modifies a printer definition

  • deletes two printer definitions.

Program

Create the PRINTERS data set and specify which actions to perform on the printer definitions. The PRINTERS data set contains the variables whose values contain the information that is needed to produce the printer definitions.

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 which 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 SAS registry, and the second Add operation creates a new printer definition for ColorPS in the SAS registry.

The Mod operation modifies the existing printer definition for LaserJet 5 in the registry.

The Del operation deletes the printer definitions for Gray PostScript and test from the registry.

The & specifies that two or more blanks separate character values. This allows the name and model value to contain blanks.

 data printers;  length name   $ 80     model  $ 80     device $ 8     dest   $ 80     opcode $ 3     ;  input opcode $& name $& model $& device $& dest $&;  datalines;  add  ColorPostScript    PostScript Level 2 (Color)           DISK   sasprt.ps  mod  LaserJet 5         PCL 5                                DISK   sasprt.pcl  del  GrayPostScript     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  ; 

Create multiple printer definitions and write them to the SAS log. The DATA= option specifies the input data set PRINTERS that contains the printer attributes. PROC PRTDEF creates five printer definitions, two of which have been deleted. The LIST option specifies that a list of printers that are created or replaced will be written to the log.

 proc prtdef data=printers library=sasuser list;  run; 

Example 5: Deleting a Single Printer Definition

Procedure features:

  • PROC PRTDEF statement option:

    • DELETE

This example shows you how to delete a printer from the registry.

Program

Create the DELETEPRT data set. The NAME variable contains the name of the printer to delete.

 data deleteprt;  name='printer1';  run; 

Delete the printer definition from the registry and write the deleted printer to the log.

The DATA= option specifies DELETEPRT as the input data set.

PROC PRTDEF creates printer definitions for the SAS registry.

DELETE specifies that the printer is to be deleted.

LIST specifies to write the deleted printer to the log.

 proc prtdef data=deleteprt delete list;  run; 



Base SAS 9.1.3 Procedures Guide (Vol. 2)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net