If you are generating multiple graph files as a result of BY processing, you can do the following in the latest SAS release:
proc sort data=sashelp.class out=class; by sex; run;
ods graphics / reset=index imagename="aTest#BYVAL(sex)";
proc sgplot data=class;
by sex;
scatter x=height y=weight;
run;
and get files aTestF.png and aTestM.png created.
... View more