04-18-2018 05:09 PM
I want to be able to create ODS graphs written to the ODS HTML destination and have the following happen:
1) The .png file is written to a different folder than the .html file
2) the graphs are named in a way that allows the user to easily identify which .png goes with which .html file
3) each time the program is run the .png and .html files are replaced
This code accomplishes this fairly well --
ods graphics on / reset=index imagename="testing" ;
ods html path="&outpath." gpath="&outpath.\png" (url="&outpath.\png\") file="testing.html";
proc sgplot data=sashelp.class noautolegend;
scatter x=age y=height / markerattrs=(symbol=squarefilled color=green);
ods html close;
EXCEPT we have programmers who work in SAS 9.4 for Windows and other programmers who work in SAS EG Version 7.13 and when this exact code is run from SAS EG the .png files created are incremented one higher than the corresponding .png files when run from SAS 9.4. It appears that SAS 9.4 starts indexing at 0, but SAS EG Version 7.13 starts indexing at 1.
Is there a way to control the indexing start point in either system?
04-18-2018 05:26 PM
The issue is probably that EG is already opening an ODS destination for you, so two graphs are created instead of one. Your code opens the second destination, so your files have an index of "1". Add this at the beginning your program and see if it works for you in EG:
ods _all_ close;
Hope this helps!
04-18-2018 05:31 PM
I tried using ODS _ALL_ CLOSE and it did not solve the problem. With ODS _ALL_ CLOSE both EG and interactive create one file -- EG names it with 1 and interactive has no extension (0). Without the ODS _ALL_ CLOSE, EG and Interactive both create two files - EG names them with 1 and 2 and Interactive names them with no extension (0) and 1.
Any other ideas?
04-18-2018 05:41 PM
EG actually does not have the ability to increment that number. The only way this can be happening, in your scenario, is that somehow another destination is still open, and was started before your ODS HTML statement. Is there any other open destinations in your program? Perhaps an ODS LISTING?
04-18-2018 05:50 PM
One other thing to check: I believe there is a way to see the full log (including the generated code from EG). Take a look at the log and see if EG is starting an ODS destination that is not getting shut down before running PROC SGPLOT.
04-18-2018 06:06 PM
One more question: is the SAS session for EG running locally on the machine with EG, or is SAS running it remotely? After re-reading your last reply, I'm wondering if EG is physically renaming the files we create to have this different index when the results are returned. Due to the hour, I cannot talk with them right now; but I'll try to find out more information.
04-18-2018 06:18 PM
Both our SAS EG and our interactive SAS run remotely on a Windows server....we connect to the same server for both, but I'm not sure what that means on the backend...
04-18-2018 06:16 PM
I used a fresh session with no autoexec etc, set the ODS CLOSE _ALL_; And in SAS EG still get that one file with the number 1 higher than what it is when I run the same code in SAS Interactive. If there is another destination open, I don't know how to track it down?
04-18-2018 11:32 PM
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.