I'm having problems with ODS graphics on/off recently. it produces unwanted output that was from previous codes.
Here is the code :
ods graphics off;
|proc univariate data=test noprint;|
histogram ttr / cfill=blue cframe=gwh vaxis=0 to 35 by 5, midpoints=0 to 200 by 10 normal( mu=est sigma=est color=RED w=1);
inset n mean (5.3) std(5.3) p10 (5.3) median (5.3) p90 (5.3) /pos=ne header='Summary Statistics' HEIGHT=3 cfill = bwh cframe=black;
|ods graphics on;|
|%graphic_template(1, 1, 1, 1, &ExcelPath, Appendix 3.2.4-02 );|
Could anyone help me with it ? I know the code is incomplete, but i think it's sufficient for you to lock in where the problem is .
Thanks for replying.
%MACRO graphic_template(across, down, startNum, endNum, oPath,oFileName);
ymult=100/&down; /* Y increment for panels. */
xmult=100/&across; /* X increment for panels. */
do x=0 to (100-xmult) by xmult; /* Calculate X coordinate values. */
llx=x; /* Lower-left X. */
ulx=x; /* Upper-left X. */
urx=x+xmult; /* Upper-right X. */
lrx=x+xmult; /* Lower-right X. */
do y=0 to (100-ymult) by ymult; /* Calculate Y coordinate values. */
lly=y; /* Lower-left Y. */
uly=y+ymult; /* Upper-left Y. */
ury=y+ymult; /* Upper-right Y. */
lry=y; /* Lower-right Y. */
proc sort data=coord;
by descending y;
set coord end=eof;
if eof then call symput('total',_n_);
%do i=%eval(&startNum+1) %to &endNum;
%let replay_num=&replay_num &nnn;
proc greplay nofs igout=work.gseg tc=work.templt template =Spec&npanels ;
filename out1 "&oPath.\&oFileName..emf";
goptions device=gif gsfname=out1 gsfmode=replace hsize = 8.33 vsize =6.03;
treplay &replay_num ;
ods listing close;
Here is the code, towards the end there is a proc greplay statement, and from the output, that's where the problem is showing. For each result, there is a univariate output(histogram) , which is correct, but also a greplay output, which is the wrong one.
Note that if i reboot SAS, so that all SAS temp files would be gone, and rerun this code, i would get the desired graphs, I think it must be with the setting of ODS or something. Hope you could help.
It's not a setting with ODS, but it is the fact that GREPLAY and SAS/GRAPH have their own numbering system for the catalog entries that are made by the procedures. When you use SAS/GRAPH to create output or GREPLAY, each of your graph images and replayed graph images gets a name and a number. The reason it works after you log off and log back on is that the temporary files in WORK.GSEG get deleted. You can mimic this by "cleaning up" WORK.GSEG before you submit your macro program.
This would delete everything in the current WORK.GSEG catalog and reset all the GOPTIONS:
proc greplay igout = work.gseg nofs;
And, this is another way to completely get rid of WORK.GSEG:
proc catalog cat=work.gseg kill force;
Just remember that ODS GRAPHICS output is NOT written to WORK.GSEG, so if you have also used ODS GRAPHICS to make images, you may or may not want to clean them up as well. But since GREPLAY only works with SAS/GRAPH, it seems likely that you will want to clean out WORK.GSEG.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.