Setting the Resolution of Your Graph

About Setting the Resolution

To set the resolution of your device-based graphics, use one of the following methods:
  • Use the IMAGE_DPI= option in an ODS LISTING or ODS HTML statement to set the image resolution, and specify one of the following Universal Printer shortcut devices: PNG, UPNG, PNGT, PNG300, SVG, SVGT, SVGVIEW, SVGZ, or UEMF. The default resolution for the PNG300 device is 300 DPI, while the default resolution for the remaining devices that are listed is 96 DPI.
    Note: Devices other than those listed do not honor the IMAGE_DPI= option.
  • Use the IMAGE_DPI= option in an ODS RTF statement to set the image resolution, and specify one of the following Universal Printer shortcut devices: PNG, UPNG, PNGT, PNG300, or UEMF.
  • Use the DPI= option in an ODS PDF, ODS PCL, ODS PS, or ODS PRINTER statement to set the image resolution. The default resolution for the ODS PDF, ODS PCL, and ODS PS destinations is 150 DPI. The default resolution for the ODS PRINTER destination is the default resolution of the printer that is used. For example, the ODS PRINTER destination produces output at 300 DPI by default when the PRINTER=PDF option is used, and it produces output at 96 DPI by default when the PRINTER=PNG option is used.
  • Use a native SAS/GRAPH device and specify the XPIXELS=, XMAX=, YPIXELS=, and YMAX= graphics options to set the resolution for graphics formats that support variable resolution. See Using the XPIXELS=, XMAX=, YPIXELS=, and YMAX= Graphics Options to Set the Resolution for the Native Devices.
  • Use a device variant to set the resolution of your graph to a specific resolution. See Using a Device Variant to Set the Size or Resolution of Your Graph.

Using the XPIXELS=, XMAX=, YPIXELS=, and YMAX= Graphics Options to Set the Resolution for the Native Devices

For the native SAS/GRAPH devices, you can use the XPIXELS=, XMAX=, YPIXELS=, and YMAX= graphics options to set the resolution of your graph. Note the following:
  • The XPIXELS=, YPIXELS=, XMAX=, and YMAX= graphics options are not supported by the default display devices and the Universal Printer devices, including the shortcut devices. These graphics options are partially supported by the ACTIVEX and JAVA devices.
  • The resolution of GIF and BMP images is fixed and cannot be changed using this method.
The XPIXELS= and YPIXELS= graphics options set the number of pixels for the X and Y axes respectively. The XMAX= and YMAX= graphics options set the maximum boundaries of the output on the X and Y axes respectively. The SAS/GRAPH software computes the resolution as follows:
X-resolution = XPIXELS / XMAX
Y-resolution = YPIXELS / YMAX
Interactions of Graphics Options That Affect Resolution summarizes the effect of the XPIXELS=, XMAX=, YPIXELS=, and YMAX= graphics options have on the image resolution.
Interactions of Graphics Options That Affect Resolution
Options Specified
Options Not Specified
SAS/GRAPH Action
XPIXELS= and YPIXELS=
XMAX= and YMAX=
Changes the dimensions and recalculates the value of XMAX= and YMAX= in order to retain the resolution.
XMAX= and YMAX=
XPIXELS= and YPIXELS=
Changes the dimensions and recalculates the value of XPIXELS= and YPIXELS= in order to retain the resolution.
XMAX= and XPIXELS=
Changes the horizontal dimension and recalculates the resolution.
YMAX= and YPIXELS=
Changes the vertical dimension and recalculates the resolution.
For example, for the graphics option settings XPIXELS=800 and XMAX=8in, the resulting X resolution is 100 DPI.
You can set the X resolution, the Y resolution, or both. Here is an example that sets the resolution of a 1000-pixel-wide-by-1200-pixel-high TIFF image of a graph to 200 DPI.
option gstyle;
ods html close;
ods listing style=seaside;
goptions reset=all device=tiffp xpixels=1000 xmax=5in ypixels=1200 ymax=6in;

proc gchart data=sashelp.cars;
   vbar Make;
      where MPG_Highway >= 37;
   run;
quit;
ods listing close;
ods html;

Using a Device Variant to Set the Size or Resolution of Your Graph

Some of the graphics output devices have variants that produce graphics of a specific size or resolution for a given format. For example, the PNG300 and JPEG300 device variants produce 300 DPI images in the PNG and JPEG format respectively.
Note: The PNG300 and JPEG300 devices are not appropriate for use with the ODS HTML destination. These devices are used when a high-resolution graph (300 DPI) in the PNG or JPEG format is required for printing purposes. Because most browsers do not use the resolution value stored in the PNG or JPEG file, images produced by the PNG300 and JPEG300 devices appear very large when they are viewed in the browser.