If your graphics look a little on the fuzzy or blurry side, there are lots of ways to increase the resolution of your SAS graphics output. Let’s go over some of these methods.
Before increasing the resolution of your graphics output, check to see what you are creating your graphics output with: A traditional SAS/GRAPH® procedure, such as GPLOT or GCHART? An SG procedure, such as SGPLOT? Or SAS® ODS Graphics with a SAS/STAT® procedure?
Using Traditional SAS/GRAPH Procedures
Here are some things that you can do to increase the resolution of your graphics output if you are using a SAS/GRAPH procedure such as GPLOT or GCHART.
Older Fonts?
First, check your code to see whether you are using older SAS/GRAPH software fonts; font names such as SWISS, CENTB, and ZAPF fall into the “older font” category. If you are using any of these, remove them from your code. Without these older software fonts in your code, SAS will by default create your graphics output with better-looking hardware fonts. For example, the Albany AMT font is one of the newer hardware fonts supplied by SAS.
Which Device Driver?
Next, check your GOPTIONS statement to see which SAS/GRAPH device driver you currently specify for the DEVICE option. If you are writing stand-alone graphics files to disk using a device driver such as PNG, JPEG, or TIFFP, replace these drivers with the PNG300, JPEG300, or TIFFP300 drivers, respectively. The PNG300, JPEG300, and TIFFP300 drivers by default create graphics output with a resolution of 300 DPI (dots per inch). By comparison, the PNG, JPEG, and TIFFP drivers create graphics output with a resolution of 96 DPI.
Using the ODS PDF Statement?
If you are using a SAS/GRAPH procedure together with the ODS PDF statement to write graphics output in PDF format, first be sure to use the SASPRTC device driver in your code, like so:
- goptions device=SASPRTC;
Then, to increase the resolution of the graphics output written to PDF, specify the DPI option in the ODS PDF FILE statement, like this:
- ods pdf file='sastest.pdf' dpi=300;
Using the ODS RTF Statement?
If you are writing your SAS/GRAPH procedure output to RTF using the ODS RTF statement, use the PNG300 device driver in a GOPTIONS statement in your code. Like this:
- goptions device=PNG300;
Using SAS SG Procedures or SAS ODS Graphics
If you are using a SAS SG procedure (such as SGPLOT) or creating graphics output using ODS Graphics with a SAS/STAT procedure, here are some things that you can do to increase the resolution of your graphics output.
If you are writing a stand-alone graphics file to disk using an ODS LISTING statement similar to this:
- ods listing gpath='c:\temp';
Then add the IMAGE_DPI option to the statement above:
- ods listing gpath='c:\temp' image_dpi=300;
Currently, SAS honors the IMAGE_DPI option in the ODS LISTING statement only when you use an SG procedure or ODS Graphics to create PNG or JPEG graphics output.
If you are writing your SG procedure and ODS Graphics output to a PDF file, you can increase the resolution of your graphics output by specifying the DPI option in the ODS PDF FILE statement, like this:
- ods pdf file='sastest.pdf' dpi=300;
If you are writing your SG procedure and ODS Graphics output to an RTF file, you can increase the resolution of your graphics output by specifying the IMAGE_DPI option in the ODS RTF statement, as in the following:
- ods rtf file='sastest.rtf' image_dpi=300;
Also, be sure to specify OUTPUTFMT=PNG in an ODS Graphics statement in your code, as shown here:
- ods graphics on / outputfmt=png;
With the SG procedures and ODS Graphics, once you increase the resolution of your graphics output, you might start seeing java.lang.OutofMemoryError or a Java heap space memory error. If you encounter this problem, see SAS Note 31184, which documents ways to address the issue by changing your SAS configuration file.
One Final Thing to Note...
Most web browsers display graphics output using fairly low resolution. So, in most situations, the resolution of graphics output displayed via web browser, is limited by the web browser itself. Therefore, when displaying graphics output via a web browser, consider creating your graphics output in scalable vector graphics (SVG) format. A previous blog post, “Have you created Scalable Vector Graphics with SAS?” describes how to create your graphics output in SVG format.
4 Comments
Thank you for your sharing!
just a further question, is it possible to configure the DPI in SAS options statement or sasv9.cfg file instead of in "ODS HTML" ?
Martin -- thank you for summarizing ways to accomplish this is various outputs. I have played with doing this many times and always quit when I got what I wanted without really understanding the "rules of the road". Then I learned all over again the next time.
I’ve been using “goptions device=PNG” to create a SAS graph or chart. If I simply replace “device=PNG” with “PNG300”, What is impact for the graph overall quality? Do I need to modify my existing code to reduce the size of graph to accommodate the change? What’s are pros and cons?
I like to hear your comments on it.
Thank you!
Ethan
Hi Ethan, In most situations, you can just replace DEVICE=PNG on your GOPTIONS statement with DEVICE=PNG300 without having to make any other changes to your code. The main difference you should see in the new graph output is that the new graph output should look better than the old graph output. It is true that the graph created with DEVICE=PNG300 will have thinner lines than with DEVICE=PNG, so if the lines with the PNG300 driver are too thin, you can increase the thickness of the lines a bit using options in your graph code.
Regards, Martin