2
votes

I am running SAS 9.4 on Windows.

If I submit

/*ods listing close;*/

filename grafout "C:\output\sastest.png"; 
goptions reset=goptions device=png gsfname=grafout;

proc gchart data=sashelp.class;
   where sex="F";
   vbar age / sumvar=weight type=mean subgroup=age 
              nolegend discrete;
run; 
quit; 

the file sastest.png is exported to the C:\output folder. However, if I place an ods listing close; statement at the top of the code, the graph is no longer exported.

Apparently, the listing destination is more than

an ODS destination that produces traditional SAS output (monospace format).

It is even more confusing because listing is turned off by default:

Beginning with SAS 9.3, by default, in the Windowing environment with the Windows and UNIX operating systems, the LISTING destination is closed and the HTML destination is open.

Why would the ods listing close; statement prevent the graph from exporting?

1
When you close the listing destination is the HTML destination still on?Reeza
are you running in Base SAS, SAS Studio or Enteprise Guide?Allan Bowe
I am using Base SAS with the Enhanced Editor. The HTML destination is still on as it has never been turned off.Lorem Ipsum

1 Answers

1
votes

The reason is because the ods listing destination is what is causing your graph to be exported via gsfname. I suspect you will find that it is indeed on before you run the code with it commented out (if it is indeed saving the file).

ODS HTML uses a different method to define where graphics should be exported rather than goptions; it uses the gpath= to define the path to the file, and the name option on the plot to define the name of the file. It is in fact "exporting" the file every time you run this - just not to a useful location (see in your log; it uses the default gpath, probably a temp location, and the default filename, the name of the proc).

ods listing close;
ods html gpath="c:\temp" ;
proc gchart data=sashelp.class;
   where sex="F";
   vbar age / sumvar=weight type=mean subgroup=age 
              nolegend discrete name="sastest";
run; 
quit; 

Your listing destination may or may not be off by default depending on your system's settings as defined by your administrator and/or other options changed during your session.

See Controlling Where Your Output Is Stored for more information about specifying how to save SAS/GRAPH files in different destinations.