BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RyanSimmons
Pyrite | Level 9

I am creating some figures using PROC SGPLOT using SAS 9.4, outputting the results as PNG files in a specific directory. My code might look like this, for example:

ods graphics / reset=index imagename='spaghetti' imagefmt=png;

ods listing gpath="&outdir.";

PROC SGPLOT data=longdat noautolegend;

       series x=month y=response / group=rexid grouplc=slope lineattrs=(pattern=1);

       yaxis values=(10 to 70 by 10);

       xaxis values=(0 to 6 by 6);

run;

However, anytime this code is run, it creates a plot called 'spaghetti1.png'. And it does so even if the directory is clear of any files, and if I open SAS and run it without running any other ods graphics statements first. For some reason, it is consistently resetting the index counter for the image names to 1, instead of 0. According to the documentation, it should only append "1" (or any other index counter) to the image name if I rerun the statement using the same image name. However, it is ALWAYS adding the 1, no matter what.

Why is the ods graphics counter not resetting to 0, thus giving me the output "spaghetti.png" as it should?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

More than likely, you have two destinations open -- the default HTML destination that opens with the session and your LISTING destination. The HTML destination creates "spaghetti.png" and the LISTING destination creates "spaghetti1.png". To remedy this, add "ODS HTML CLOSE;" to the beginning of your program.

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

More than likely, you have two destinations open -- the default HTML destination that opens with the session and your LISTING destination. The HTML destination creates "spaghetti.png" and the LISTING destination creates "spaghetti1.png". To remedy this, add "ODS HTML CLOSE;" to the beginning of your program.

RyanSimmons
Pyrite | Level 9

So, adding ODS HTML CLOSE before this code works, but I don't understand what the problem is.

There are no other ODS calls in the code before this, so it is going from SAS's default settings. The only other code in the program before that PROC SGPLOT are DATA steps. Why is it defaulting to having two destinations open?

DanH_sas
SAS Super FREQ

Starting with SAS 9.3, we open up an HTML destination by default to provide a default viewer for all output (instead of just a graph window for device-based graphics). This happens in the SAS session without any requiring any ODS statements. When you specified your LISTING destination, you just opened up one more destination. Had you opened up an HTML destination with a filename, the default HTML destination would have automatically closed.

With that said, you can disable the automatic HTML destination by going to Tools->Options->Preferences..., selecting the "Result" tab, and unchecking the HTML destination.

Hope this answers all of your questions.

Thanks!

Dan

RyanSimmons
Pyrite | Level 9

Makes sense!

Thanks a lot, Dan.

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
  • 4 replies
  • 3539 views
  • 4 likes
  • 2 in conversation