4
votes

In SAS 9.3, I could use ODS HTML GPATH to specify the path where I wanted graphs to be saved (if I so desired). In 9.4, by default (i.e. every time I open SAS) whenever I make a graph (with PROC SGPLOT, e.g.), it automatically saves the plot to the location where the SAS program is saved. I've tried going to Tools --> Options --> Preferences --> Results and unchecking every combination of the HTML and ODS options, but no matter what I'm still getting automatically saved graphs. How can I turn this off? Preferably I'd still have ODS output within SAS, but I do not want these PNG (or whatever) images to be saved to my computer outside SAS automatically.

EDIT: More information because the differences as stated above were not clear.

1) In 9.3 I had to say ODS GRAPHICS ON and specify ODS HTML GPATH in order to have SAS save my plots to my computer outside of SAS (or so I thought). If I wanted ODS graphics inside of SAS, but not save graphs outside of SAS, I could just say ODS GRAPHICS ON and skip the ODS HTML GPATH statement.

2) When I open 9.4 and do not make any statements about ODS (i.e. leave settings at default), but run a procedure such as SGPLOT, I A) get both a html graph (ODS graph that shows up in SAS's 'Results' window) and a graph that I can double-click to open in Windows Photo Viewer, and B) the plot is additionally and automatically saved where my SAS program is located as a PNG.

Trying to stop this automatic graphing saving, I have tried the following in SAS 9.4 before running PROC SGPLOT:

1) ODS GRAPHICS OFF: Nothing changes. I still get everything listed in point (2) above.

2) ODS HTML CLOSE (with ODS GRAPHICS ON): Lose html/ODS version of graph within SAS, but still have graph in SAS I could double-click that opens in Windows Photo Viewer, and still the graph saves automatically to my SAS program's location.

3) ODS GRAPHICS OFF and ODS HTML CLOSE: Same thing as previous case ((2) directly above).

What I want (and I feel like this is how it was in 9.3) is to yes, have ODS graphs come up within SAS (don't really need the version you can double-click to open in Windows Photo Viewer), but no, do not have SAS save a PNG to my computer (specifically, my SAS program's location).

3
Can you be a bit more specific with the difference (as I'm not aware of a difference from 9.3 to 9.4 in this). In 9.3 did you have HTML or Listing as your default destination (listing was the 9.2 and earlier default)? In the 9.3 example you say you are using GPATH to define the path (which is the correct way to do so); in 9.4 you don't explicitly say this doesn't work, but is that what you mean? Can you post an example short program that doesn't work how you want it in 9.4 but does in 9.3?Joe
I can't recall 9.3 offhand, but believe both listing and HTML were checked by default, and this is for sure how it is in 9.4. The issue is not being able to assign a path, but rather that the path seems assigned by default so that SAS automatically saves a graph even when I have not told it to (i.e. I haven't specified ODS HTML GPATH). I have done some editing above, so hopefully that helps clarify.Meg
It has to save them somewhere, if you have not specified a gpath (see Don's answer, then). Otherwise, how is it going to show you the images? You may want them stored in your work directory, in which case you could set up an autoexec to automatically define your initial gpath to be your work directory.Joe
I thought that, just like output and temporary data sets, that SAS could display graphs within SAS, and then delete them when SAS is closed. I am surprised to think that every graph I ever made in SAS is saved somewhere? I just don't want them. Period. I want them to be deleted when I close SAS. Is this not possible?Meg

3 Answers

7
votes

First off, a few notes about what you tried.

ODS GRAPHICS on/off will not have any real effect on SGPLOT or any of the SG procedures; they are all ODS GRAPHICS no matter what. What it does affect is PROC UNIVARIATE and similar procedures that have two types of graphics - old style graphics and ODS GRAPHICS. ODS GRAPHICS ON tells them to use ODS GRAPHICS, and OFF tells them to use the older method.

ODS HTML CLOSE will tell SAS not to produce HTML output, but as long as you have another destination open (ODS LISTING?) it will produce graphs still to the GRAPH destination. Addtionally, the fact that it still produces graphics at all with ODS HTML CLOSE (as opposed to the note "No output destinations active" and no output) tells me you still have a destination open (again, probably LISTING). Thus, ODS HTML GPATH will not necessarily solve your problem (as it will only impact where the HTML output will go). You need to set GPATH for each open destination (which is either LISTING, HTML, or both, depending on the checkboxes in your preferences).

The solution: Since you want it to go away, your best bet is to make it in your work directory (which is cleaned up by SAS when it properly shuts down).

ods listing gpath="%sysfunc(getoption(work))";

proc sgplot data=sashelp.class;
vbar sex;
run;

Note that the .png files are created (as they always are), but now they go into the work catalog (which you can browse like a sub-library and see each of the files inside).

You could put the initial line in an autoexec.sas file and tell SAS to run that when SAS starts up (-AUTOEXEC option on command line).

You also could uncheck Listing in tools->preferences->Results, and/or use ODS LISTING CLOSE;, and those files should not appear.

1
votes

Go to Tools --> Options --> Preferences --> Results and uncheck Create listing. It should take care of the automatic saving of PNG files to your program files.

0
votes

In 9.3, when ODS HTML is on, graphs are defaulted to the user's home directory. They are saved to the hard drive, even if you don't specify a path. Otherwise, there is no way for the browser to display the images. The default location may have moved in 9.4 (I don't have a copy to test), but both versions put png files on your hard drive.