title: Adding graph count in footnote in SAS
body: <p>Hi I am trying to use BY GROUP statement in SAS to generate multiple graphs. I want to print each graph to an individual file named after BY GROUP varaible value, plus I want to add a footnote to each graph where I want add text "This graph is 2300-01" to graph 1 and the want to increment it by 1 for next graph to "This graph is 2300-02" and so on.</p>
  
  <pre><code>goptions reset=all border;
  data grainldr;
  length country $ 3 type $ 5;
  input year country $ type $ amount;
  megtons=amount/1000;
  datalines;
  1995 BRZ  Wheat    1516
  1995 BRZ  Rice     11236
  1995 BRZ  Corn     36276
  1995 CHN  Wheat    102207
  1995 CHN  Rice     185226
  1995 CHN  Corn     112331
  1995 INS  Wheat    .
  1995 INS  Rice     49860
  1995 INS  Corn     8223
  1995 USA  Wheat    59494
  1995 USA  Rice     7888
  1995 USA  Corn     187300
  ; 
  
   proc sort data=grainldr out=temp;
   by country;
   run;
  
   proc sgplot data=temp (where=(megtons gt 31));
   by country;
  
   series x=type y= amount;
   series x=type y=megtons;
   title "Leading #byval(country) Producers"
      j=c "1995 and 1996";
   footnote1 j=r  "This graph is 2300-&amp;XY."; 
   run;
  </code></pre>
  
  <p>quit;</p>