<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add Year to File Name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481997#M124780</link>
    <description>&lt;P&gt;Imagine fiscal years that start in Feb and end in Jan.&amp;nbsp;&amp;nbsp;&amp;nbsp; Then you would probably label that year the same as the calendar year containing february.&amp;nbsp; SAS has such yearly intervals.&amp;nbsp; Specificaly "year.2" as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yearname=year(intnx("year.2"),datadate,0,"begin");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The interval "year.2" is a year beginning FEB and ending JAN.&amp;nbsp; Adding 0 such years to your date, and then aligning&amp;nbsp; the result to the beginning of the interval produces a date value of 01FEBxxxx.&amp;nbsp; The&amp;nbsp; year function extracts the xxxx.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Embedding this in a series of %sysfunc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let testdate=01jan2018;
%let syear=%sysfunc(year(%sysfunc(intnx(year.2,%sysfunc(inputn(&amp;amp;testdate,date9.)),0,begin))));
%put &amp;amp;=syear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Jul 2018 19:23:01 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-07-27T19:23:01Z</dc:date>
    <item>
      <title>Add Year to File Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481981#M124770</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to extract current/previous year and use it in my file name.&amp;nbsp; I want to extract current year (2018)&amp;nbsp;if not January and extract previous year (2017)&amp;nbsp;if it's January.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;

data _null_;
	%let testdate=01JANE2018;
	%let cmons=%sysfunc(month("&amp;amp;testdate"d));

	if &amp;amp;cmons = 1 then;
	%let syear= %sysfunc(year(%sysfunc(intnx(year,%SYSFUNC("&amp;amp;testdate"d)),-1))));
	else;
	%let syear= %sysfunc(year("&amp;amp;testdate"d));
run;

%put &amp;amp;cmons &amp;amp;syear;
ods _all_ close;
ods tagsets.excelxp
	file="c:\Reports\me_Q%sysfunc(intnx(qtr,%sysfunc(date()),-1), qtr.)_&amp;amp;syear..xls"
	style=sasweb;
ods tagsets.excelxp options(sheet_name="me_Q%sysfunc(intnx(qtr,%sysfunc(date()),-1), qtr.)_&amp;amp;syear");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 19:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481981#M124770</guid>
      <dc:creator>BonnaryW</dc:creator>
      <dc:date>2018-07-27T19:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add Year to File Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481996#M124779</link>
      <description>Do have non macro working code? If so, post that first and also please take the time to explain what the issue is with the code above. &lt;BR /&gt;&lt;BR /&gt;If you don't that's usually where I recommend you start. In addition, it's clear that this is only part of your code.</description>
      <pubDate>Fri, 27 Jul 2018 19:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481996#M124779</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-27T19:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add Year to File Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481997#M124780</link>
      <description>&lt;P&gt;Imagine fiscal years that start in Feb and end in Jan.&amp;nbsp;&amp;nbsp;&amp;nbsp; Then you would probably label that year the same as the calendar year containing february.&amp;nbsp; SAS has such yearly intervals.&amp;nbsp; Specificaly "year.2" as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yearname=year(intnx("year.2"),datadate,0,"begin");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The interval "year.2" is a year beginning FEB and ending JAN.&amp;nbsp; Adding 0 such years to your date, and then aligning&amp;nbsp; the result to the beginning of the interval produces a date value of 01FEBxxxx.&amp;nbsp; The&amp;nbsp; year function extracts the xxxx.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Embedding this in a series of %sysfunc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let testdate=01jan2018;
%let syear=%sysfunc(year(%sysfunc(intnx(year.2,%sysfunc(inputn(&amp;amp;testdate,date9.)),0,begin))));
%put &amp;amp;=syear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Jul 2018 19:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/481997#M124780</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-07-27T19:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add Year to File Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/482011#M124788</link>
      <description>&lt;P&gt;It's&amp;nbsp;Worked !! Thank you very much for simplify my codes and the explanations.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 19:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Year-to-File-Name/m-p/482011#M124788</guid>
      <dc:creator>BonnaryW</dc:creator>
      <dc:date>2018-07-27T19:42:48Z</dc:date>
    </item>
  </channel>
</rss>

