<?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 Us %sysfunc or %substr to create fiscal year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337655#M76712</link>
    <description>&lt;P&gt;I'm doing something on my data files that contain fiscal year values (e.g. 1314, 1415) in the file name, and my %do %to year valus are 4-digit values (e.g. 2014, 2015). How do I create fiscal year values using such as sysfuncs? Here is the sample code. The one I wrote didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have2014; input id;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data have2015; set have2014; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro renm;&lt;BR /&gt;%do year=2014 %to 2015;&lt;BR /&gt;%let fy= %substr(&amp;amp;year,3,2)%sysfunc(putn(%eval(substr(&amp;amp;year,3,2).+1),z2.))&lt;BR /&gt;data want&amp;amp;year; set have&amp;amp;fy;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%renm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the input file names are have1415, have1516, and&lt;/P&gt;
&lt;P&gt;I'd like to produce output file names want2014 and 2015.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 22:56:41 GMT</pubDate>
    <dc:creator>Solph</dc:creator>
    <dc:date>2017-03-02T22:56:41Z</dc:date>
    <item>
      <title>Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337655#M76712</link>
      <description>&lt;P&gt;I'm doing something on my data files that contain fiscal year values (e.g. 1314, 1415) in the file name, and my %do %to year valus are 4-digit values (e.g. 2014, 2015). How do I create fiscal year values using such as sysfuncs? Here is the sample code. The one I wrote didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have2014; input id;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data have2015; set have2014; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro renm;&lt;BR /&gt;%do year=2014 %to 2015;&lt;BR /&gt;%let fy= %substr(&amp;amp;year,3,2)%sysfunc(putn(%eval(substr(&amp;amp;year,3,2).+1),z2.))&lt;BR /&gt;data want&amp;amp;year; set have&amp;amp;fy;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%renm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the input file names are have1415, have1516, and&lt;/P&gt;
&lt;P&gt;I'd like to produce output file names want2014 and 2015.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 22:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337655#M76712</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2017-03-02T22:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337671#M76720</link>
      <description>&lt;P&gt;Relying on the last statement in your post, here is an example of how to change from have1415 to want2014 (and also from have1516 to want2015).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro renm;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;%local year fy;&lt;BR /&gt;&lt;SPAN&gt;%do year=2014 %to 2015;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;%let fy= %substr(&amp;amp;year,3,2);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;%let fy = &amp;amp;fy%sysfunc(putn(%eval(&amp;amp;fy&lt;/SPAN&gt;&lt;SPAN&gt;+1),z2));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data want&amp;amp;year; set have&amp;amp;fy;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%mend;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%renm&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I can't test it right now, and it looks only mildly different than your original. &amp;nbsp;In fact, if you had changed SUBSTR to %SUBSTR in your longer statement, it might have worked. &amp;nbsp;(Removing the dot after z2 probably works either way.)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 23:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337671#M76720</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-02T23:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337672#M76721</link>
      <description>&lt;P&gt;%let fy= %substr(&amp;amp;year,3,2)%eval(%substr(&amp;amp;year,3,2)+1);&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 23:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337672#M76721</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-02T23:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337673#M76722</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that would work for the years in the example, but would lose the leading zero when one exists in the second half of the fiscal year.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 00:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337673#M76722</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-03T00:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337674#M76723</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;You are correct &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is why I always create my macro variables in a data step rather than macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fy= %substr(&amp;amp;year,3,2)%sysfunc(putn(%eval(%substr(&amp;amp;year,3,2)+1), z2.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 00:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337674#M76723</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-03T00:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Us %sysfunc or %substr to create fiscal year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337925#M76827</link>
      <description>&lt;P&gt;Thanks a lot.&amp;nbsp;It worked and for pointing the obvious errors I missed and the concatenated line by Reeza:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; fy&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token macroname"&gt;%substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;putn&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;%eval&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;%substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; z2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have1415; input id;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data have1516; set have1415; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro renm;&lt;BR /&gt;%do year=2014 %to 2015;&lt;BR /&gt;%let fy= %substr(&amp;amp;year,3,2)%sysfunc(putn(%eval(%substr(&amp;amp;year,3,2)+1), z2.));&lt;BR /&gt;data want&amp;amp;year; set have&amp;amp;fy; run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%renm;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 17:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Us-sysfunc-or-substr-to-create-fiscal-year/m-p/337925#M76827</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2017-03-03T17:40:46Z</dc:date>
    </item>
  </channel>
</rss>

