title: Automating the starting date with a macro variable in SAS
body: <p><strong>Background:</strong>
  I have a code that pulls transactional data starting at the beginning of the current calendar quarter, but from an year ago. 
  For example, if I run the code today (August 16, 2013) it will have to pull all the data from July 1, 2012 onwards.</p>
  
  <p><strong>Problem:</strong>
  I want to automate the starting date for the data pull with a macro variable.</p>
  
  <p>So far, I'm stuck here:</p>
  
  <pre><code>%let ThisYear = %Sysfunc(Date(), YEAR.);
  %let LastYear= %eval(&amp;ThisYear-1); /* I get the starting year */
  
  %let QTR_start_month= %eval(3*%Sysfunc(Date(), qtr.)-2); /* this gives me the current quarter starting month. If I run it in August, it outputs 7 for July */
  
  %let start_date=%str(01/%Sysfunc(month(&amp;QTR_start_month))/&amp;lcy);
  </code></pre>
  
  <p>The final macro variable outputs the date which I want, but in a format which is not recognized by SAS.</p>
  
  <p>I will greatly appreciate any help.
  Many thanks in advance!</p>