Universal Printing

What Is Universal Printing?

Universal Printing is a printing system that provides both interactive and batch printing capabilities to SAS applications and procedures on all operating environments that are supported by SAS. Universal Printing enables you to define printers and print previewers, and to control most printing options as your output is created. In addition to sending output to a printer, you can print to external files.
Windows Specifics: By default, the Windows operating environment uses Windows printing and not Universal Printing. For more information about using Universal Printing under Windows, see Setting Up the Universal Printing Interface and the Default Printing Environment.
SAS routes all printing through Universal Printing services. All Universal Printing features are controlled by system options, thereby enabling you to control many print features, even in batch mode. For more information about these system options, see System Options That Control Universal Printing.
Note: Before the introduction of Universal Printing, SAS supported a utility for print jobs known as Forms. Forms printing is still available if you select Filethen selectPrint Setup from the menu, then check the Use Forms check box. This turns off Universal Printing menus and functionality. For more information, see Forms Printing.

Setting Up the Universal Printing Interface and the Default Printing Environment

Universal Printing is enabled when SAS starts in the UNIX or z/OS operating environment. Under Windows, Windows printing is enabled when SAS starts. To use Universal Printing in Windows, you must set the UNIVERSALPRINT system option to enable the Universal Printing menus and dialog boxes, and to set up the printing defaults. This option can be set only in a SAS configuration file or at start-up. You cannot enable or disable Universal Printing menus and dialog boxes after SAS starts.
Windows Specifics: In the Windows operating environment, include the following system option when you start SAS:
-uprint
UPRINT is an alias for the UNIVERSALPRINT system option.
Note: When you use the PRINTERPATH= system option to specify a printer, the print job is controlled by Universal Printing. To return to Windows printing, set the PRINTERPATH= system option to a null string: PRINTERPATH=''.

Universal Printing Output Formats

In addition to sending print jobs to a printer, you can also direct output to external files that are widely recognized by different types of printers and software programs. You can use Universal Printing to produce the following commonly recognized file types.
Available Print Output Formats
Type
Full Name
Description
GIF
Graphics Interchange Format
An image format designed for the online transmission and interchange of graphic data. The format is widely used to display images on the World Wide Web because of its smaller size and portability.
EMF
Enhanced Metafile Format
A metafile format that is a collection of graphic drawing commands, configuration properties, and graphic objects to create true color, scalable, device-independent graphics. Applications that support EMF run on Windows.
PCL
Printer Control Language
Developed by Hewlett-Packard as a language that applications use to control a wide range of printer features across a number of printing devices. Universal Printing currently supports PCL4, PCL5, PCL5e, and PCL5c levels of the language.
PDF
Portable Document Format
A file format developed by Adobe Systems for viewing and printing a formatted document. To view a file in PDF format, you need Adobe Reader, a free application distributed by Adobe Systems.
Note: Adobe Acrobat is not required to produce PDF files with Universal Printing.
PNG
Portable Network Graphics
An image format that was designed as a replacement for the older simple GIF format and the more complex TIFF format. As with GIF, one of the major uses of PNG is to display images on the World Wide Web. PNG has these major advantages over GIF on the Web: gamma correction, two-dimensional interlacing, variable transparency (alpha channel), setting the resolution, and more than 256 colors.
PS
PostScript
A page description language developed by Adobe Systems.
SVG
Scalable Vector Graphics
A vector format that is a language for describing two-dimensional graphics and graphical applications in XML.
You set the value of the PRINTERPATH= system option to a universal printer or use ODS statements to create output in one of the above formats. When the PRINTERPATH= system option is set to a printer that prints to a file, the default filename is sasprt.extension. extension is the printer format type. Here are some example filenames: sasprt.pdf, sasprt.emf, sasprt.png, and sasprt.gif. The file is written to the current directory.
You can use the PRINTERPATH= system option to change the location and the name of the file. Here is an example:
options printerpath=(svg out);
filename out 'c:\myimages\graph1.svg';

Viewing Universal Printers and Printer Prototypes

SAS provides universal printers and printer protypes that you can use to create your own printers. You can access the list of available printers from the Print dialog box, or you can use the QDEVICE procedure to create a data set of printers and then print the printer information that you want using the PRINT procedure.
To create a table of printers and print the list with a description of each printer, submit this code:
proc qdevice out=printers;
   printer _all_;
run;

proc print data=printers;
   var name desc;
   where nametype contains "Printer";
run;
For more information, see QDEVICE Procedure in Base SAS Procedures Guide.
To print a list of printer prototypes to the SAS log, submit this SAS program:
filename registry temp;
proc printto log=registry;
run;

proc registry list keysonly levels=1 startat="core\printing\prototypes";
proc printto;
run;

data protypes;
   keep prototype;
   infile registry;
   length line $256;
   input line $256.;
   if substr(line,1,1) = "["
     then do;
        prototype = substr(line,2,length(line)-2);
        output;
     end;
run;

proc print label;
   label prototype = "Prototype";
run;
For more information, see REGISTRY Procedure in Base SAS Procedures Guide.

Viewing Universal Printer Settings

You can use the QDEVICE procedure or the Print dialog box to view the settings of a universal printer. To view printer settings using the QDEVICE procedure, submit this code:
proc qdevice;
printer printer-name;
run;
Here are the printer settings for the GIF printer:
15   proc qdevice;
16   printer gif;
17   run;

                 Name: GIF
          Description: Graphics Interchange Format RGB Color/Alpha Blending
                 Type: Universal Printer
             Registry: SASHELP
            Prototype: GIF rgba
     Default Typeface: Cumberland AMT
           Font Style: Regular
          Font Weight: Medium
          Font Height: 8 points
       Maximum Colors: 16777216
         Visual Color: True Color
        Color Support: RGBA
          Destination: sasprt.gif
             I/O Type: DISK
          Data Format: Other
               Height: 6.25 inches
                Width: 8.33 inches
              Ypixels: 600
              Xpixels: 800
           Rows(vpos): 50
        Columns(hpos): 114
          Left Margin: 0 inches
  Minimum Left Margin: 0 inches
         Right Margin: 0 inches
 Minimum Right Margin: 0 inches
        Bottom Margin: 0 inches
Minimum Bottom Margin: 0 inches
           Top Margin: 0 inches
   Minimum Top Margin: 0 inches
       XxY Resolution: 96x96 pixels per inch
   Compression Method: None
       Font Embedding: Never
The QDEVICE procedure does not report all printer settings. For a description of the printer settings that can be reported, see QDEVICE Procedure in Base SAS Procedures Guide.

Modifying Universal Printing Printer Settings

You modify printer settings using the universal printer dialog boxes, by setting SAS system options, or by using the PRTDEF procedure. See the following topics:

Universal Printing and ODS

The ODS PRINTER statement can use Universal Printing whether the UNIVERSALPRINT or NOUNIVERSALPRINT system option is set. The PRINTER destinations used by the ODS PRINTER statement are described in the ODS PRINTER Statement in SAS Output Delivery System: User's Guide.
The Output Delivery System (ODS) uses Universal Printing for the following ODS statements.
ODS Statements That Use Universal Printing
ODS Statement
Description
ODS PRINTER PRINTER= option
Uses the selected printer.
ODS PDF statement
Uses the Universal Printing PDF printer.1
ODS PS statement
Uses the Universal Printing PostScript Level 1 printer.
ODS PCL statement
Uses the Universal Printing PCL5 printer.
1You must have SAS/GRAPH installed to create drill-down regions in a graph created by the PDF universal printer. For more information, see Adding Drill-Down Graphs in Your PDF File in SAS/GRAPH: Reference.
Windows Specifics: In the Windows operating environment, the ODS PRINTER destination uses the Windows system printers unless SAS is started with the UNIVERSALPRINT system option, or when you specify a printer with the PRINTERPATH= system option. If Universal Printing is enabled in Windows, SAS overrides the use of the Windows system printer and causes ODS to use Universal Printing. To return to Windows printing, set the PRINTERPATH= system option to a null string: PRINTERPATH=''.
For more information about ODS, see SAS Output Delivery System: User's Guide.

Specifying the Page Orientation for Universal Printing Documents

You can specify the page orientation for each page of a multiple-page document that is created by a universal printer or for documents that are created for the ODS LISTING, PCL, PDF, PRINTER, and PS destinations.
The ORIENTATION= system option has four values: PORTRAIT, LANDSCAPE, REVERSEPORTRAIT, and REVERSELANDSCAPE. To change the orientation of a document page, specify the OPTIONS statement, using the ORIENTATION= system option, between the steps that create output to change the page orientation.
The following example creates a four-page SVG document. The orientation is changed between landscape and portrait for each page in the document. The OPTIONS statements are highlighted:
options nodate nonumber;
ods printer printer=svgview file='orientation.svg' style=Ocean;
title 'Demonstration of Page Orientation Changes in a Document';
footnote 'PROC SGPLOT in Landscape Orientation';
options orientation=landscape;
proc sgplot data=sashelp.class;
vbar age;
run;

options orientation=portrait;
footnote 'PROC PRINT in Portrait Orientation';
proc print data=sashelp.class;
run;

options orientation=landscape;
footnote 'PROC SGSCATTER in Landscape Orientation';
proc sgscatter data=sashelp.cars;
matrix mpg_city enginesize horsepower / 
   diagonal=(histogram kernel);
run;

options orientation=portrait;
footnote 'PROC MEANS in Portrait Orientation';
proc means data=sashelp.cars n mean;
   var  mpg_city enginesize horsepower;
run;

ods printer close;
The following output shows the third and fourth pages of the document. The third page has a landscape orientation and the fourth page has a portrait orientation.
Page Three of an SVG Document Showing the Landscape Orientation
Page Three of an SVG Document Showing the Landscape Orientation
Page Four of an SVG Document Showing the Portrait Orientation
Page Four of an SVG Document Showing the Portrait Orientation
For more information, see ORIENTATION= System Option in SAS System Options: Reference.

Color Support for Universal Printers

Universal Printers and the Color Spaces They Support

All universal printers support 24-bit RGB colors. Most printers support 32-bit CMYK colors or 32-bit RGBA (transparency) colors. The following table shows the color support by universal printers.
Color Support for Universal Printers
Universal Printer
Color Support
Supports Transparency
EMF
RGBA only for bitmap images. RGB for vector elements
Yes, for bitmap images only
GIF
RGBA
Yes
PCL5c1
RGBA
Yes
PDF
CMYK and RGBA
Yes, for RGBA colors
PNG
RGBA
Yes
PostScript
CMYK and RGB
No
SVG
RGBA
Yes
1PCL4 and PCL5 Universal Printers support only monochrome printing.
For information about CYMK, RGB, and RGBA colors, see CMYK Colors and RGB and RGBA Colors.

CMYK Colors

CMYK colors setting specify eight hexadecimal characters with a value of 0–255 to specify the amount of cyan, magenta, yellow, and black ink. Use your printer’s Pantone Color Look-up table to find the CMYK values for your printer. If you specify an unsupported color, such as a CMYK color with an EMF printer, the color is converted to a color that is supported.
You can specify CMYK colors where ever colors can be set (for example, in the PROC PRINT statement STYLE option or in the TITLE statement).
Preface the hexadecimal number with a CMYK or a K. Here are some examples of CMYK colors that you can set in SAS:
Example CMYK Colors
Hexadecimal Representation
Color
cmykFF000000
cyan
k00FF0000
magenta
cmyk0000FF00
yellow
kFFFF0000
blue
cmykFF00FF00
green
k00FFFF00
red
cmykFFFFFF00
process black, using cyan, magenta, and yellow
k000000FF
black
The first byte of the hexadecimal number represents cyan. The second byte represents magenta. The third byte represents yellow. The fourth byte represents black.
This example uses the STYLE option to set the column background color to magenta and sets the foreground color to white. The TITLE statement sets the output title to blue.
options obs=5 nodate;
ods html close;
ods pdf;
proc print data=sashelp.demographics label 
           style(header)={background=cmyk00ff0000 foreground=k00000000} noobs;
   var name pop;
   label name=Country Name pop=Population;
   title color=kffff0000 'Demographics 2005';
run;
ods pdf close;
ods html;
CMYK Color Specified in the STYLE Option
CMYK Color Specified in the STYLE Option

RGB and RGBA Colors

RGB and RGBA colors combines red, green, and blue colors in different ratios to create colors. The A is the alpha channel, which represents a percentage of opacity.
You specify RGB colors as a triple of hexadecimal numbers, ranging from 00–FF, where each hexadecimal number indicates how much of the red, green, or blue is included in the color. RGBA color includes an additional hexadecimal number for the alpha channel that indicates how transparent the color is. FF is opaque and 00 is transparent. In both RGB and RGBA color specifications, the first hexadecimal number is red, the second, is green, and the third is blue. In RGBA colors, the fourth hexadecimal number is the alpha channel specification.
You can specify RGB and RGBA colors where ever colors can be set (for example, as an option in the VBAR statement in the SGPLOT procedure or in the TITLE statement). For RGB colors, preface the hexadecimal number with a CX. For RGBA colors, preface the hexadecimal number with RGBA or A.
The following SGPLOT procedure uses an RGBA color to create the bar labels:
ods html close;
ods printer printer=png;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title color=a6495edff "Stock Volume vs. Close";
   vbar date / response=volume
               datalabel
               datalabelattrs=(color=a8a44ff8a size=10);
   vline date / response=close y2axis;
run;
title;
ods printer close;
ods html;
Here is the PNG file with bar labels:
RGBA Color Specified for the Bar Labels
RGBA Color Specified for the Bar Labels

Example: Static and Varying Background Color in a Table Using RGBA Colors

This example program does the following:
  • Creates the format PCT. using a DATA _NULL_ statement. The DATA step defines salary ranges of $3,000.00 and calculates an RGBA color value for each salary range. The CALL EXECUTE statement is used to output the FORMAT procedure code as it is generated.
  • Creates a data set.
  • The PRINT procedure uses an RGBA color value for the background of the table header and formats the salary variable using the PCT. format.
options nodate;

/* Create the PCT format.                                */
/* The color variable is a concatenation of calculated   */
/* hexadecimal values.                                   */

data _null_ ;
   call execute('proc format fmtlib ; value pct');
   max=10000;
   maxloop=255; 
   do i=1 to maxloop by 10;
      color='RGBA'||put(((maxloop)/(maxloop+i)*200),hex2.)
                  ||put(((maxloop)/(maxloop+i)*235),hex2.)
                  ||put(((maxloop)/(maxloop+i)*255),hex2.)||'95';
      from=max;  
      to=(max+3000); 
      max=max+3000;
      /* Create salary ranges of $3000.00 equal to the calculated RGBA color value.*/
      call execute(put(from,best.)||'-'||put(to,best.)||'='||quote(color));
   end;

    
   /* Create RGBA values for missing values and values outside the salary ranges.  */ 
   call execute('.="RGBAF7F5F0480" other="RGBAFF2A2A88"; run;');
 run;

data staff;
   infile datalines dlm='#';
   input Name $16. IdNumber $ Salary
         Site $ HireDate date7.;
   format hiredate date7.;
   datalines;
Capalleti, Jimmy# 2355# 21163# BR1# 30JAN09
Chen, Len#        5889# 20976# BR1# 18JUN06
Davis, Brad#      3878# 19571# BR2# 20MAR84
Leung, Brenda#    4409# 34321# BR2# 18SEP94
Martinez, Maria#  3985# 49056# US2# 10JAN93
Orfali, Philip#   0740# 50092# US2# 16FEB03
Patel, Mary#      2398# 35182# BR3# 02FEB90
Smith, Robert#    5162# 40100# BR5# 15APR66
Sorrell, Joseph#  4421# 38760# US1# 19JUN11
Zook, Carla#      7385# 22988# BR3# 18DEC10
;
run;
ods html close;
ods pdf file='outpdf.pdf';
proc print data=staff noobs label 
           style(HEADER)={background=rgbac7eafe95  fontstyle=italic} 
           style(DATA)={foreground=black};
   var name IdNumber ;
   var salary /style(DATA)={background=pct.};
	 label IdNumber='Employee Number' salary='Salary in U.S. Dollars';
   format salary dollar7.;
   title 'Generated Colors for the Variable Salary';
run;
ods pdf close;
Here is the SAS log:
501  options nodate;
502
503  /* Create the PCT format.                                */
504  /* The color variable is a concatenation of calculated   */
505  /* hexadecimal values.                                   */
506
507  data _null_ ;
508     call execute('proc format fmtlib ; value pct');
509     max=10000;
510     maxloop=255;
511     do i=1 to maxloop by 10;
512        color='RGBA'||put(((maxloop)/(maxloop+i)*200),hex2.)||put(((maxloop)/(maxloop+i)*235),
512! hex2.)
513               ||put(((maxloop)/(maxloop+i)*255),hex2.)||'95';
514        from=max;
515        to=(max+3000);
516        max=max+3000;
517
518        /* Create salary ranges of $3000.00 equal to the calculated RGBA color value.*/
519        call execute(put(from,best.)||'-'||put(to,best.)||'='||quote(color));
520     end;
521
522     /* Create RGBA values for missing values and values outside the salary ranges.  */
523     call execute('.="RGBAF7F5F0480" other="RGBAFF2A2A88"; run;');
524   run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
NOTE: CALL EXECUTE generated line.
1   + proc format fmtlib ;
1   +                      value pct
2   +        10000-13000="RGBAC7EAFE95"
3   +        13000-16000="RGBABFE1F495"
4   +        16000-19000="RGBAB8D9EB95"
5   +        19000-22000="RGBAB2D1E395"
6   +        22000-25000="RGBAACCADB95"
7   +        25000-28000="RGBAA6C3D495"
8   +        28000-31000="RGBAA1BDCD95"
9   +        31000-34000="RGBA9CB7C795"
10  +        34000-37000="RGBA97B2C195"
11  +        37000-40000="RGBA93ADBB95"
12  +        40000-43000="RGBA8FA8B695"
13  +        43000-46000="RGBA8BA3B195"
14  +        46000-49000="RGBA879FAC95"
15  +        49000-52000="RGBA849BA895"
16  +        52000-55000="RGBA8097A495"
17  +        55000-58000="RGBA7D93A095"
18  +        58000-61000="RGBA7A909C95"
19  +        61000-64000="RGBA778C9895"
20  +        64000-67000="RGBA74899595"
21  +        67000-70000="RGBA72869195"
22  +        70000-73000="RGBA6F838E95"
23  +        73000-76000="RGBA6D808B95"
24  +        76000-79000="RGBA6B7D8895"
25  +        79000-82000="RGBA687B8595"
26  +        82000-85000="RGBA66788395"
27  +        85000-88000="RGBA64768095"
28  + .="RGBAF7F5F0480" other="RGBAFF2A2A88";
NOTE: Format PCT has been output.
28  +                                         run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


525
526  data staff;
527     infile datalines dlm='#';
528     input Name $16. IdNumber $ Salary
529           Site $ HireDate date7.;
530     format hiredate date7.;
531     datalines;

NOTE: The data set WORK.STAFF has 10 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


542  ;
543  run;
544
545  /* Close the HTML destination and open the PDF destination.*/
546  /* Format the header background using an RGBA color.       */
547  /* Use the PCT. format to format the salary variable.      */
548
549  ods html close;
550  ods pdf file='outpdf.pdf';
NOTE: Writing ODS PDF output to DISK destination "c:\public\mySASPrograms\outpdf.pdf",
      printer "PDF".
551  proc print data=staff noobs label
552             style(HEADER)={background=rgbac7eafe95  fontstyle=italic}
553             style(DATA)={foreground=black};
554     var name IdNumber ;
555     var salary /style(DATA)={background=pct.};
556       label IdNumber='Employee Number' salary='Salary in U.S. Dollars';
557     format salary dollar7.;
558     title 'Generated Colors for the Variable Salary';
559  run;

NOTE: There were 10 observations read from the data set WORK.STAFF.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


560  ods pdf close;
NOTE: ODS PDF printed 1 page to c:\public\mySASPrograms\outpdf.pdf.
561  ods html;
NOTE: Writing HTML Body file: sashtml7.htm
Here is the formatted PDF output:
A PDF File Formatted using RGBA Color Values