BookmarkSubscribeRSS Feed
bunnycao
Calcite | Level 5

Hi,

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;

run; 

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 !

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi: What is inside your %graphic_template macro program? The PROC UNIVARIATE step?

cynthia

bunnycao
Calcite | Level 5

Hi Cynthia,

Thanks for replying.

%MACRO graphic_template(across, down, startNum, endNum, oPath,oFileName);                                                                                                 

                                                              

  %let npanels=%eval(&down*&across);                                                                                                                                      

                                                                                                                                                                          

  data numgraf;                                                                                                                                                           

      ymult=100/&down;                         /* Y increment for panels. */                                                                                              

      xmult=100/&across;                       /* X increment for panels. */                                                                                              

   run;                                                                                                                                                                   

      data coord;                                                                                                                                                            

      set numgraf;                                                                                                                                                        

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

            output;                                                                                                                                                       

         end;                                                                                                                                                             

      end;                                                                                                                                                                

   run;                                                                                                                                                                   

                                                                                                                                                                          

   proc sort data=coord;                                                                                                                                                  

      by descending y;                                                                                                                                                    

   run;                                                                                                                                                                   

                                                                                                                                                                          

   data mccoord;                                                                                                                                                          

      set coord end=eof;                                                                                                                                                  

      call symput('llx'||left(_n_),llx);                                                                                                                                  

      call symput('ulx'||left(_n_),ulx);                                                                                                                                  

      call symput('urx'||left(_n_),urx);                                                                                                                                  

      call symput('lrx'||left(_n_),lrx);                                                                                                                                  

      call symput('lly'||left(_n_),lly);                                                                                                                                  

      call symput('uly'||left(_n_),uly);                                                                                                                                  

      call symput('ury'||left(_n_),ury);                                                                                                                                  

      call symput('lry'||left(_n_),lry);                                                                                                                                  

      if eof then call symput('total',_n_);                                                                                                                               

   run;                                                                                                                                                                   

%let replay_num=&startNum:1;                                                                                                                                              

%let n=2;                                                                                                                                                                 

%do i=%eval(&startNum+1) %to &endNum;                                                                                                                                     

        %let nnn=&i:&n;                                                                                                                                                   

        %let replay_num=&replay_num &nnn;                                                                                                                                 

        %let n=%eval(&n+1);                                                                                                                                               

%end;                                                                                                                                                                     

%put &replay_num;                                                                                                                                                         

ods listing;                                                                                                                                                              

proc greplay nofs igout=work.gseg tc=work.templt  template =Spec&npanels ;                                                                                                

   tdef spec&npanels                                                                                                                                                      

   %tempdef;                                                                                                                                                              

filename out1 "&oPath.\&oFileName..emf";                                                                                                                                  

goptions device=gif gsfname=out1 gsfmode=replace  hsize = 8.33  vsize =6.03;                                                                                              

  treplay &replay_num ;                                                                                                                                                   

quit;                                                                                                                                                                     

ods listing close;                                                                                                                                                        

%MEND;   

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. 

Cynthia_sas
SAS Super FREQ

Hi:

  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;
  delete _all_;
run;
quit;

   
goptions reset=all;

  And, this is another way to completely get rid of WORK.GSEG:

proc catalog cat=work.gseg kill force;

run;

quit;

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.

cynthia

bunnycao
Calcite | Level 5

Thanks Cynthia, this is very helpful !

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1016 views
  • 0 likes
  • 2 in conversation