Creating PNG (Portable Network Graphics) Using Universal Printing

Portable Network Graphics in SAS

Portable Network Graphics (PNG) is an image format that was designed to replace GIF and TIFF image formats that are viewed on the World Wide Web. PNG images that are created with the SAS universal printer or a SAS/GRAPH device driver use the PNG Reference Library, also known as libpng. The PNG universal printer is the default printer for the ODS PNG, ODS HTML, and ODS LISTING destinations.
For a description of the PNG printer, you can either view the printer in the SAS registry or submit the following QDEVICE procedure and view the output in the SAS log:
proc qdevice;
   printer png;
run;

The PNG Universal Printers

SAS provides three PNG universal printers.
PNG Universal Printers Provided by SAS
Printer Name
Description
PNG
produces PNG images at 96 dpi
PNGt
produces PNG images at 96 dpi with a transparent background
PNG300
produces PNG images at 300 dpi

Creating a PNG Image

You can create a PNG image using the ODS PRINTER statements. You specify the PNG universal printer as the value of the PRINTERPATH= system option or as the value of the PRINTER= option in the ODS PRINTER statement.
Here is sample code to create a PNG image:
ods html close;
ods printer printer=png;

...more SAS code...

ods printer close;
ods html;
SAS creates the file sasprt.png in the current directory.
In SAS/GRAPH, the PNG device is a shortcut to the PNG universal printer. For information about creating PNG images using SAS/GRAPH devices, see SAS/GRAPH: Reference.

Example of Creating a PNG File Using the ODS PRINTER Statement

To create a PNG image in SAS using one of the PNG universal printers, specify the PNG printer in the PRINTERPATH= system option and the ODS PRINTER statement as shown in the following example:
options printerpath=png nodate;
ods html close;
ods printer;
proc sgplot data=sashelp.stocks
  (where=(date >= "01jan2000"d and stock = "IBM"));
  title "Stock Trend";
  series x=date y=close;
  series x=date y=low;
  series x=date y=high;
run;
ods printer close;
ods html;
The following output is the PNG graphic displayed in Windows Picture and Fax Viewer:
A PNG Image Using ODS Printer
A PNG Image Using ODS Printer

Web Browsers and Viewers That Support PNG Files

Although many browsers support PNG images, the following browsers, using the specified version or later, support most PNG image capabilities:
  • Microsoft Internet Explorer 7.01b
  • Mozilla Firefox 1.5.0.4
  • Netscape Navigator 6
  • Irfan View for Windows
  • Microsoft Photo Editor
  • Windows Picture and Fax Viewer
For more information about browsers and viewers that support PNG images, see the PNG Web pages at www.libpng.org.