<?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: How to set fiscal year2019 [Apr2018 to Mar2019] in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463937#M118260</link>
    <description>&lt;P&gt;Is this a correct understanding of your requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Every sample date belongs to a fiscal year (01aprxxxx-31marxxxy) where xxxy=xxxx+1.&lt;/LI&gt;
&lt;LI&gt;start month is 2 years (sameday) preceding the sample date.&amp;nbsp; (It's really start day, not start month, right?).&lt;/LI&gt;
&lt;LI&gt;enddate is 01janxxxx,&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If these are your rules then you could construct the first day of the fiscal year containing sample_date as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fy_start_date=intnx('year.4',sample_date,0,'begin');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The YEAR.4 interval is a year beginning on April 01.&amp;nbsp; So the above adds 0 fiscal years to sample_date, and aligns the result to the beginning of the fiscal year - i.e. 01APR.&amp;nbsp; Then it's easy to get 01JAN of the same year.&amp;nbsp; For instance:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;enddate=mdy(1,1,year(fy_start_date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or in a single assignment&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;enddate=mdy(1,1,year(intnx('year.4',sample_date,0,'begin')));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 May 2018 00:00:44 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-05-22T00:00:44Z</dc:date>
    <item>
      <title>How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463712#M118188</link>
      <description>&lt;P&gt;I have to set start_date and end_date from the cycle date.&lt;/P&gt;&lt;P&gt;If the Cycle Date: 28th April 2018 then the:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Start Month: Apr 2016 – Exactly 2 years backdated. the below code I have fix for that.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SAS CODE:&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Curr_Date= '28APR2018'd;&lt;/P&gt;&lt;P&gt;start_date=intnx('year', &amp;amp;Curr_Date, -2,"sameday");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly the &lt;STRONG&gt;end_date&lt;/STRONG&gt; should always be Jan &lt;STRONG&gt;with respective year from cycle date and fiscal year&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Example:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;End_date: Jan 2016 –&amp;gt;&amp;nbsp; &amp;nbsp;should always be Jan 2016 for the fiscal year2017 [Apr2016 to Mar2017]&lt;/LI&gt;&lt;LI&gt;End_date: Jan 2018 –&amp;gt;&amp;nbsp; &amp;nbsp;should always be Jan 2018 for the fiscal year2019 [Apr2018 to Mar2019]&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Can you please provide me some sample code how to fix it?&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 06:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463712#M118188</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-05-21T06:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463716#M118189</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39525"&gt;@Spintu&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Not sure that I've understood the logic you're after. Does below return your desired result?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  format 
    have_dt date9.
    start_fisc_dt date9.
    want_dt date9.
    ;
  input have_dt :date9.;

  /* start of fiscal year for have_dt */
  start_fisc_dt=intnx('year.4',have_dt,0,'b');

  /* 01 january date in calendar date of start date of fiscal year */
  want_dt=intnx('year.4',start_fisc_dt,0,'b');

  datalines;
01JAN2016
31MAR2016
01APR2016
31DEC2016
01JAN2017
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 300px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20638iBA8ACAE23498139A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 07:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463716#M118189</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-21T07:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463732#M118192</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Actually my concern is&amp;nbsp; I have a&amp;nbsp; &lt;STRONG&gt;Cycle Date: 28th April 2018.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Start_date&lt;/STRONG&gt; should be trigger from &amp;nbsp;: Apr 2016 – Exactly 2 years backdated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end_date&lt;/STRONG&gt;&amp;nbsp; should be dynamically change&amp;nbsp;based on fiscal year.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End_date: Jan 2017 – should always be Jan 2017 for the fiscal year2018 [Apr2016 to Mar2017]&lt;/P&gt;&lt;P&gt;Again the end_date will change from [Apr 2017 to Mar2018] the end_date it should be : Jan2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense for your understanding.&lt;/P&gt;&lt;P&gt;I wrote the below SAS code , however I m not sure end_date output it has be resolve two times in dynamically&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS CODE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Curr_Date= '28APR2018'd;&lt;BR /&gt;%let sysyear= %sysfunc(year("&amp;amp;Curr_Date"d));&lt;BR /&gt;%put&amp;nbsp; &amp;amp;sysyear;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;file print;&lt;BR /&gt;format date end_date start_date date9.;&lt;/P&gt;&lt;P&gt;do month=1 to 12;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; start_date=intnx('year', &amp;amp;Curr_Date, -2,"sameday");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; date=mdy(month,1,&amp;amp;sysyear);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fedfiscalyear = year(start_date) + (month(date) le 3);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end_date="01JAN&amp;amp;sysyear"d;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put date= mmddyy10. fedfiscalyear=&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx("startdate",start_date);&lt;BR /&gt;&amp;nbsp;call symputx("end_date",end_date);&amp;nbsp;&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;startdate. &amp;amp;end_date.;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 09:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463732#M118192</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-05-21T09:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463897#M118251</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39525"&gt;@Spintu&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I'm still not sure that I understand. Using the data I've posted why don't you show us what the desired want_dt should be when using your logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you describe you should be able to use the INTNX() function also for your end_date calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 21:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463897#M118251</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-21T21:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463937#M118260</link>
      <description>&lt;P&gt;Is this a correct understanding of your requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Every sample date belongs to a fiscal year (01aprxxxx-31marxxxy) where xxxy=xxxx+1.&lt;/LI&gt;
&lt;LI&gt;start month is 2 years (sameday) preceding the sample date.&amp;nbsp; (It's really start day, not start month, right?).&lt;/LI&gt;
&lt;LI&gt;enddate is 01janxxxx,&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If these are your rules then you could construct the first day of the fiscal year containing sample_date as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fy_start_date=intnx('year.4',sample_date,0,'begin');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The YEAR.4 interval is a year beginning on April 01.&amp;nbsp; So the above adds 0 fiscal years to sample_date, and aligns the result to the beginning of the fiscal year - i.e. 01APR.&amp;nbsp; Then it's easy to get 01JAN of the same year.&amp;nbsp; For instance:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;enddate=mdy(1,1,year(fy_start_date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or in a single assignment&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;enddate=mdy(1,1,year(intnx('year.4',sample_date,0,'begin')));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 00:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/463937#M118260</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-22T00:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to set fiscal year2019 [Apr2018 to Mar2019]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/469187#M119965</link>
      <description>&lt;P&gt;start month is 2 years (sameday) preceding the sample date.&amp;nbsp; (It's really start day, not start month, right?).&lt;/P&gt;&lt;P&gt;That's correct it is start day. Now I am able to calculate end date based on fiscal year. It is working fine for me.&lt;/P&gt;&lt;P&gt;thank you very much.&amp;nbsp; Sorry for delayed your response due to family matter.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 12:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-fiscal-year2019-Apr2018-to-Mar2019/m-p/469187#M119965</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-06-11T12:10:17Z</dc:date>
    </item>
  </channel>
</rss>

