05-05-2017 02:07 AM
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.
05-05-2017 02:39 AM
ODS listing is text-only. Think of a 133-column typewheel or drum-type printer. Graphics where done by using positioned characters.
05-05-2017 10:01 AM
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:
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.
05-06-2017 06:39 AM
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?
05-06-2017 11:35 AM
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. :-(
05-08-2017 04:09 AM
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.