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.
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.
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.