Pregunta

Hi I am ploting some data using BY GROUP option, and saving each plot to a separate file. I want to add an auto figure number to each plot title or footnote.

Lets say I have three BY GROUP variable levels, so i will have 3 plots saved to three files. I want to add either titles or footnotes of:

title "Figure 01. Plot of #byval"; or footnote "Figure 01. Plot of #byval"; 
title "Figure 02. Plot of #byval"; or footnote "Figure 02. Plot of #byval"; 
title "Figure 03. Plot of #byval"; or footnote "Figure 03. Plot of #byval"; 

Here i added 01, 02 and 03 manually but I want to automate it so that I could give a start value and it automatically increment by 1, until the last level of BY GROUP variable.

Your help will be greatly appreciated. Thanks

¿Fue útil?

Solución

Have two BY variables where the first BY variable is "01", "02" etc, and then use:

title "Figure #byval1. Plot of #byval2";

Otros consejos

this could be accomplished by macro. The follows is an example.

    %macro bygraph(dset=,byvar=);

     %do i=1 %to %sysfunc(countw(&byvar));
     %let byvari=%sysfunc(scan(&byvar,&i));
       proc sort data=&dset; 
        by &byvari;
       run;

      ods rtf file="plot&i..rtf" startpage=no; 
/*output,modify as you need.the graph will be stored to plot1.rtf, plot2.rtf... */
       proc plot data=&dset;
        by &byvari;
        plot .... ;  /* your plot statements */
        title "Figure &i Plot of &byvari"; 
       run;
       quit;
      ods rtf close;
     %end;

     %mend;

    /* run macro, fill in data set, byvars (separated by blanks) as parameters */
    %bygraph(dset=dataset, byvar=var1 var2 var3); run;  
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top