Tip on creating graphic files in specific locations

3
When trying to write out graphics to a specific filename location, the gsfname option is only honored when ODS LISTING is turned on and ODS HTML is turned off. This is especially important in 9.3 Base SAS as the ODS HTML option is the default output destination. Enterprise Guide users will also find themselves in this same scenario when using only the SAS Report output option.
Correcting this is pretty straightforward by adding the ODS LISTING statement.
Included below is a sample of this code that uses the GSFNAME= option to write the gif graph out to c:\temp. The differences are highlighted in blue text.
When initially attempting the code I noticed that the code works and there are no errors however the gif is sent to my temporary location. After adding the ODS options (seen in blue in the 'Code After' column), the graph is written to the correct folder.
Code Before Code After
filename grafout 'c:\temp\sastest.gif';
goptions reset=all device=gif gsfname=grafout gsfmode=replace;
proc gtestit; run;
ods listing;
filename grafout 'c:\temp\sastest.gif';
goptions reset=all device=gif gsfname=grafout gsfmode=replace;
proc gtestit; run;
Logs Before Logs After
NOTE: 125 records written to
C:\Users\anhall\AppData\Local\Temp\SAS Temporary
Files\_TD8252_L73453_\gtestit1.gif
...

NOTE: PROCEDURE GTESTIT used (Total process time):
real time 1.70 seconds
cpu time 0.76 seconds

NOTE: 125 records written to
C:\Users\anhall\AppData\Local\Temp\SAS Temporary
Files\_TD8252_L73453_\gtestit4.gif
NOTE: 125 records written to c:\temp\sastest.gif
...

NOTE: PROCEDURE GTESTIT used (Total process time):
real time 0.29 seconds
cpu time 0.23 seconds

When only using ODS LISTING; the same graphics output is still written out to the temporary location. This is because the HTML destination is still open. If I added the statement ODS HTML CLOSE; along with the ODS LISTING; then no files would be forwarded into the temporary location.

Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

3 Comments

  1. Hi Angela,

    Thank you for this usefull tips.

    I am having trouble when I have more then one file that I want to save to specific folder.

    For example, In one SAS program I have two SAS PROC GPLOT and I am saving two different output graphs to specific folder using the GSFNAME GOPTIONS. I have closed HTML and opened ODS LISTING.

    Unfortunetly, I can only save the first graph to the specif folder but the second one still gets sent to temp folder.

    I am using SAS EG 4.3. Any help would be appericiated on this.

    Thank You

  2. Thanks for the valuable tip. In EG, it was difficult to generate .gif files at a specific location.

Back to Top