Hi,
I am trying to use ODS combining with macro to save png plots. The first time I submit the following codes:
%Let param1=Intercept;
%Let param2=x;
/* Save png */
%macro m_hist;
%Do para=1 %to 2;
Ods graphics / imagename="&¶m¶" imagefmt=png;
Proc univariate data=combination;
Title "Histogram of &¶m¶";
Where Variable="&¶m¶";
Var Estimate;
Histogram Estimate/ odstitle="Histogram of &¶m¶";
Run;
%End;
%mend;
%m_hist;
I get two files Intercept1.png and x1.png.
This is unusual since I set the names without number 1 at the end.
I submit the macro program again, %m_hist;, this time I get Intercept3.png and x3.png. The third time I submit I get Intercept5.png and x5.png.
That is not what I expect. Do you have any idea?
Thanks for reading!
Kind regards,
Trung Dung.
The numbers at te end if file names have nothing to do with your macro. They are added by the ODS to avoid overwriting existing files as explained here:
Change your statement to
Ods graphics / imagename="&¶m¶" imagefmt=png reset=index;
to force overwriting.
that is because of this statement:
%Do para=1 %to 2;
so you are getting the results that are specified.
Hi @VDD,
I think the file names are fixed as &¶m¶ is resolved as "Intercept" when i=1 and "x" when i=2. Could you explain more?
the do loop is setting ¶.
The numbers at te end if file names have nothing to do with your macro. They are added by the ODS to avoid overwriting existing files as explained here:
Change your statement to
Ods graphics / imagename="&¶m¶" imagefmt=png reset=index;
to force overwriting.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.