SAS: Get current year in YY format
<p>I want to assign the current year in a YY format to either a macro or data set variable.</p>

<p>I am able to use the automatic macro variables <code>&amp;sysdate</code> or <code>&amp;sysdate9</code> to get the current date.  However, extracting the year in a YY format is proving to be a nightmare.  Below are some examples of what I've been trying.</p>

<p>There exists the <a href="http://support.sas.com/documentation/cdl/en/leforinforref/63324/HTML/default/viewer.htm#p0jwqba6i1r0j1n1xe9ovnn0pamr.htm" rel="nofollow noreferrer">YEARw.</a> format.  But when I try to use it I get errors or weird results.  For instance, running</p>

<pre><code>data _null_;
  yy = year(input("&amp;sysdate9.", year2.));
  put  yy=;
run;
</code></pre>

<p>produces the error</p>

<pre><code>ERROR 48-59: The informat YEAR was not found or could not be loaded.
</code></pre>

<p>If I try to format the variable in the output, I get 1965 instead of the current year.  The following </p>

<pre><code>data _null_;
  yy = year(input("&amp;sysdate9.", date9.));
  put  yy= yy year2.;
run;
</code></pre>

<p>outputs</p>

<pre><code>yy=2016 65
</code></pre>

<p>Please help.</p>