title: SAS macro code to generate mean sales for a particular year
body: <p>I am trying to write a macro code that generates average sales for a particular year. Say today I want report for year=2008 and tomorrow for year=2009.
  The data has Order_date variable which is in format mmddyy10.</p>
  
  <p>I am trying to achieve that by the following code:</p>
  
  <pre><code>%macro yearly(yr=%sysfunc(year("&amp;sysdate"d )); 
  
  proc means data=salesxls;
  class &amp;yr;
  where year(order_date) == &amp;yr;
  title "yearly avg sales for &amp;yr";
  run;
  
  %mend yearly;
  </code></pre>
  
  <p>This is not working. The reason could be the %sysfunc I used to extract the year. Any help would be appreciated.
   P.S A Macro newbie here</p>
  
  <p>EDIT:
  The code for single year that works is as follows:</p>
  
  <pre><code>data new;
  
  set work.salesxls;
  
  yr=year(Order_date);     /** I extracted the year from Order_date)**/
  
  run;
  
  proc means data=new mean;
  
  class yr;
  
  var total_retail_price;
  
  where yr=2008;
  
  run;
  </code></pre>
  
  <p>In the code above I first created a data set which has extracted year. Then I used that data for proc means procedure.</p>