BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10

I want to generate a png file through ods listing and ods graphics, and I found a wired thing, with the name of png file.

My code is:

ods listing gpath='D:\' dpi=300 style=htmlblue;
ods graphics/reset=all imagename='test' imagefmt=png;
proc sgplot data=sashelp.class;
  scatter x=height y=weight/group=sex;
run;
ods _all_ close;

Condition A:

There is 0 result at results window. Run the code and get a png file named "test1.png";

Condition B:

There is at least 1 result at results window. Run the code and get a png file named "test.png";

 

How it happens? I want the result is always "test.png", what shoud I do?

Thanks for any advice.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

If you have more than one ODS destination open, more than one Image file might be created. So for your case, it is best to close any open ODS destinations to make sure only one image file is created.

View solution in original post

4 REPLIES 4
whymath
Lapis Lazuli | Level 10
My SAS version is SAS9.4 TS1M5.
BrunoMueller
SAS Super FREQ

I suggest to close all ODS destinations before you start creating your graph, see example below.

To always get the same filename use 

ods graphics / reset=index;

Sample code:

ods _all_ close;
ods listing gpath='c:\temp' style=htmlblue;
ods graphics/ reset=index imagename='test' imagefmt=png;
proc sgplot data=sashelp.class;
  scatter x=height y=weight/group=sex;
run;
ods _all_ close;
whymath
Lapis Lazuli | Level 10
Amazing! Could you please explain how the first "ods _all_ close;" affect the filename?
BrunoMueller
SAS Super FREQ

If you have more than one ODS destination open, more than one Image file might be created. So for your case, it is best to close any open ODS destinations to make sure only one image file is created.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 692 views
  • 0 likes
  • 2 in conversation