title: Using intnx to get the same date last year in SAS
body: <p>I want to pull the same date one year before my variable 'day_3_ago'</p>
  
  <p>My code: </p>
  
  <pre><code>%macro date; 
  data _null_;
  call symput ('day_3_ago', put(intnx('day',today(),-3, 'b'),yymmddn8.));
  run;
  %mend;
  
  %date;
  
  %let last_year_3dayago = [1 year before day_3_ago]
  </code></pre>
  
  <p>For example, if I ran this code today, day_3_ago would be 20170624. I would want last_year_3dayago to be 20160624</p>
  
  <p>My current solution is: </p>
  
  <pre><code>%let last_year_3daygo = %sysfunc(intnx(day,%sysfunc(inputn(&amp;day_3)ago.,yymmdd8)),-365),yymmddn8);
  </code></pre>
  
  <p>but that doesn't account for leap years.    </p>