BookmarkSubscribeRSS Feed
ECProthena
Fluorite | Level 6

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 --

%let outpath=Y:\Sandbox\Testing\Tools;
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);
run;
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?

 

8 REPLIES 8
DanH_sas
SAS Super FREQ

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!

Dan

ECProthena
Fluorite | Level 6

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?

DanH_sas
SAS Super FREQ

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?

DanH_sas
SAS Super FREQ

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.

 

Thanks!

Dan

DanH_sas
SAS Super FREQ

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.

 

Thanks!
Dan

ECProthena
Fluorite | Level 6

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...

ECProthena
Fluorite | Level 6

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?

 

PGStats
Opal | Level 21

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.

 

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1323 views
  • 0 likes
  • 3 in conversation