BookmarkSubscribeRSS Feed
BruceBrad
Lapis Lazuli | Level 10

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.

 

5 REPLIES 5
Jay54
Meteorite | Level 14

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.

BruceBrad
Lapis Lazuli | Level 10

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?

Jay54
Meteorite | Level 14

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.  😞

BruceBrad
Lapis Lazuli | Level 10

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2326 views
  • 1 like
  • 3 in conversation