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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.