Data visualization with SAS programming

Configuration for high resolution png graphics

Reply
Frequent Contributor
Posts: 129

Configuration for high resolution png graphics

I'm using sgplot to produce graphics to place into a MSWord document. I have a procedure that works, but it is pretty awkward. I'm sure there must be a simpler way.

 

options orientation=portrait;
goptions reset=goptions ;
ods graphics on / reset=index width = 20cm height=20cm border=off;
ods listing style=fancyprinter gpath="c:\temp\SASImages" image_dpi=600;
ods html  style=fancyprinter image_dpi=600;

proc sgplot;
[code]

This produces a plot in the results viewer that is is low-resolution. However, if I look in the temp\SASimages folder I find a high-resolution png file that I can insert into my document. I also get some warnings about the Java VM running out of memory.  I'm guessing that there must be a more straightforward way (and that some of my code is redundant). For a start, I don't really understand the difference between the ods listing and ods html options.

 

Esteemed Advisor
Posts: 6,698

Re: Configuration for high resolution png graphics

ODS listing is text-only. Think of a 133-column typewheel or drum-type printer. Graphics where done by using positioned characters.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
SAS Super FREQ
Posts: 1,081

Re: Configuration for high resolution png graphics

It helps if you include the SAS version you are using and the full code so we can see what is going on.  That said, ODS LISTING will produce high resolution graphs is stand alone image files (PNG, etc).  You can then insert this graph into your word doc.  Or, if you really want a graph in the Word doc, use RTF destination.

 

If you specify a large file size and high DPI, Java system can run out of memory needed for the large raster image.  You can use the information in the log to increase Java memory.  Update your sasv9.cfg file and add the following to the -JREOPTIONS= (  ) section and restart SAS:

  -Xms1024m
  -Xmx1024m

 

If you don't want to do that, try reducing the dpi to 300-400.

 

Also, if you have 9.4 or later, you can produce a SVG or PDF output that uses "Scalable vector graphics), and will not use up large amount of Java memory.

Frequent Contributor
Posts: 129

Re: Configuration for high resolution png graphics

Thanks Sanjay, I'll make that change to the Java config. I find high resolution png files to be a simple and robust way of including graphics in documents (600dpi allows me to flexibly resize them), so I'll stick with this method for now. I'm using SAS 9.4 (TS1M3) on X64_7PRO.

Why do I get low resolution graphics in the results viewer, but high resolution files in the gpath folder? Also, to be honest, I'm not sure why my standard setup has a ODS HTML configuration statement as well. Is this not needed?

SAS Super FREQ
Posts: 1,081

Re: Configuration for high resolution png graphics

A high res (600 dpi) image is created in both html and listing destinations.  But, when displayed in the brower, the browser will "scale" the image by dpi to fit in the page.  Usually, browsers do a very poor job of scaling.  If you view source on the html file and look at the included image directly, you will it is also hi res.  The file created in Listing is easy to find in the Results Window.  

 

You do not need the html destination, but it is on by default.  You can close it to avoid duplicate outputs.  Keep only the Listing destination open.  Alternatively, you can create SVG to get vector output (instead of raster) and that will scale infinitely and display well in the browser, but I'm not sure how to insert SVG files in Word.  I think it first has to be converted to a raster file.  :-(

Frequent Contributor
Posts: 129

Re: Configuration for high resolution png graphics

Thanks. I think the following config does what I need:

ods graphics on / reset=index width = 20cm height=20cm border=off;
ods html  style=bbfp gpath="c:\temp\SASImages"  image_dpi=600;

Not having the ods listing option stops me getting two copies of everything. (I want to keep the html results window open to get html tables). The figures in the results editor are still low-res, but the high-res versions can be found in the gpath folder.

 

Curiously, I still get the Java VM warning even after changing the Java memory parameters - but the program runs fine.

Ask a Question
Discussion stats
  • 5 replies
  • 160 views
  • 1 like
  • 3 in conversation