3

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

Joe
  • 62,789
  • 6
  • 49
  • 67
Meg
  • 696
  • 1
  • 7
  • 20
  • 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 Jan 19 '14 at 01:09
  • 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 Jan 19 '14 at 15:10
  • 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 Jan 19 '14 at 15:19
  • 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 Jan 19 '14 at 15:23

3 Answers3

7

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.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • Thank you for your response. Two things happen when I run the two ODS lines you give above: 1) I get a file called sashtml saved at the location of my SAS program (didn't happen before) and 2) I no longer get a graph visible in SAS. The graph that would normally show up in the 'Results' window is a black "X" (like when an image doesn't load). – Meg Jan 19 '14 at 15:49
  • @Meg Corrected. I adjusted my SAS session to match yours, and I'm fairly sure `ODS LISTING` is the sole source of your problem - HTML seems to behave. If HTML isn't behaving, right click on the results page (anywhere in the HTML page) and select 'properties', and see where that file is being stored, and put that as part of your OP. For me, it's being stored in file:///c:/saswork/(...) which is where my SAS work directory is located. – Joe Jan 19 '14 at 16:02
  • [Note: This comment is going to span two comments b/c of its length.] Okay, that does work. As an aside, however, if I choose listing only for my non-graphical output (i.e. I uncheck "Create HTML", which is my preference), then it doesn't work. Instead of getting a graph in the 'Results' tab that I can double-click to open in SAS's 'Results' window (normally has an Internet Explorer icon next to it), I get an icon that looks like a notepad with a question mark and it won't open. – Meg Jan 19 '14 at 16:30
  • Adding back in `ODS HTML GPATH=work.graphcat;` does not alleviate the problem. Curiously, if I have my output as listing only and instead of `ods listing gpath=work.graphcat;` specify `ods listing gpath="C:\Users\Megan\AppData\Local\Temp";` (and don't do anything with `ods html`), which is where the path was when I looked at the properties as you suggested, my output works as listing only, but for the graphs I only get a plot that I can double-click and open in Windows Photo Viewer, but it doesn't open in SAS's 'Results' window itself. – Meg Jan 19 '14 at 16:32
  • As another aside, I really wish I had access to 9.3 so I could try to figure out where it's saving these graphs. I just can't believe it's this difficult to change something like this. What a mess. – Meg Jan 19 '14 at 16:33
  • You may want to ODS LISTING GPATH=(something else), then. Catalogs should work, but perhaps not for this purpose . You can save it to a file, as you did in your above comment (you could also save it to your work directory, using `%sysfunc(getoption(work))`.) – Joe Jan 19 '14 at 16:57
  • Edited to reflect the folder - that works in LISTING only in my SAS 9.4. I will check 9.3 when I get to work if I remember (Tuesday). – Joe Jan 19 '14 at 17:01
  • Yes, it allows listing only, but then I still do only get that graph that I have to open in Windows Photo Viewer - I don't get SAS automatically bringing up the graph in the 'Results' window. It is a good work-around for now :^) Thank you for your patience and help! I will keep playing with it... – Meg Jan 19 '14 at 17:33
  • @Meg It works properly in my 9.4 session, so perhaps you have something else checked incorrectly (do you have "View Results as They Are Generated" checked?) – Joe Jan 20 '14 at 01:50
  • I do have "View results as they are generated" checked, yes (it defaults to this for me). Do you not? I will try it w/o that checked. – Meg Jan 20 '14 at 16:57
  • I do have it checked. I'm using a basic installation of 9.4 almost out-of-the-box default settings. – Joe Jan 20 '14 at 17:38
  • And you have "Create HTML" unchecked? If I have this unchecked it doesn't give me a plot I can open in SAS, but if I have it checked, it does. I decided I can live with this. I can just go to my 'Output' window for my listed output (and ignore the ODS output in the 'Results' window) and go to the 'Results' window when I want to look at a graph. Using your code above, yes, the graphs are not saved outside of SAS and are deleted when SAS closes. I will consider this a closed case! Thank you for your help! – Meg Jan 20 '14 at 18:18
1

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.

mischva11
  • 2,811
  • 3
  • 18
  • 34
0

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.

DomPazz
  • 12,415
  • 17
  • 23
  • 1
    This is where I'm confused by the OP; she references in 9.3 using `GPATH` (which is how you could change this to a different location) which should also work in 9.4. – Joe Jan 19 '14 at 02:10
  • I agree. I think she doesn't understand that the pngs are put on the hard drive in both versions. The location in 9.4 might have changed to make it more apparent. – DomPazz Jan 19 '14 at 02:20
  • I'm confused by this statement because whenever I used 9.3 I did NOT get graphs saved outside of SAS unless I specified `ODS HTML GPATH` (unless they were going somewhere I didn't know about). If I just turned on ODS graphics using `ODS GRAPHICS ON`, I got that output *within* SAS, but graphs were not saved outside of SAS. I have edited my initial question in hopes of clarifying. – Meg Jan 19 '14 at 15:12
  • It sounds like SAS apparently is always saving graphs somewhere. As I said in a comment in the above response, this surprises me to think that every SAS graph I've ever made is saved somewhere? Why can they not just be active within SAS and then deleted when SAS is closed like output and temporary data sets are? – Meg Jan 19 '14 at 15:25
  • Well, that 'somewhere' could be your work folder, of course, which does get deleted. – Joe Jan 19 '14 at 15:30
  • Yes, thank you - that will work as a solution. Your answer above has been selected. Thanks everyone. – Meg Jan 20 '14 at 18:19