<?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 Coding with multiple Fiscal Year Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462546#M117779</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA Year18_19;
INPUT Date1 Course_ID $4. age 3.;
INFORMAT Date1 Date9.;
FORMAT Date1 Date9.;
DATALINES;
05Jan2018 ENG1 10
16Feb2018 Bio2 15
09Apr2018 Che1 10
15Jan2018 Bio1 11
11MAY2018 Eng2 15
09Mar2018 Phy2 11
20Feb2018 Che1 15
;
RUN;

PROC PRINT DATA=Year18_19 NOOBS;
RUN;

DATA Year17_18;
INPUT Date1 Course_ID $4. age 3.;
INFORMAT Date1 Date9.;
FORMAT Date1 Date9.;
DATALINES;
05Jan2018 ENG1 10
16Jan2017 Bio2 15
09Feb2017 Che1 10
15Mar2018 Bio1 11
11MAY2017 Eng2 15
22Apr2017 Phy2 11
20Feb2018 Che1 15
;
RUN;

PROC PRINT DATA=Year17_18 NOOBS;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi,&lt;BR /&gt;My Fiscal Year goes from March 01 to February 30. When I am in the month of May now, I want to pull all the data for this fiscal year (from dataset Year18_19 above) UNTIL last month.&lt;BR /&gt;and I want the system to calculate that from sysdate.&lt;/P&gt;
&lt;P&gt;So for this fiscal year code should return the following observations from dataset Year18_19:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Date1 Course_ID age&lt;/STRONG&gt;&lt;BR /&gt;09Apr2018 Che1 10&lt;BR /&gt;11MAY2018 Eng2 15&lt;BR /&gt;09Mar2018 Phy2 11&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Now I want to do the same for the last Fiscal year (Year17_18) which will return:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Date1 Course_ID age&lt;/STRONG&gt;&lt;BR /&gt;05Jan2018 ENG1 10&lt;BR /&gt;11MAY2017 Eng2 15&lt;BR /&gt;22Apr2017 Phy2 11&lt;BR /&gt;20Feb2018 Che1 15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to follow the following code to accomplish it, but I really can't get anything out of it. I will really appreciate any help on this.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let previous_month = %sysfunc(
intnx( MONTH , %sysfunc( today() ) , -1)
, yymmN6.);



%MACRO fy (date , start=7);
year(&amp;amp;date) + (month(&amp;amp;date) ge &amp;amp;start and &amp;amp;start ne 1)
%MEND;



DATA try_FY;
this_date = date();
FiscalYear = %FY( this_date , start = 3 );
PUTLOG FiscalYear = Txn_Date=date9.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2018 02:58:22 GMT</pubDate>
    <dc:creator>mlogan</dc:creator>
    <dc:date>2018-05-16T02:58:22Z</dc:date>
    <item>
      <title>Coding with multiple Fiscal Year Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462546#M117779</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA Year18_19;
INPUT Date1 Course_ID $4. age 3.;
INFORMAT Date1 Date9.;
FORMAT Date1 Date9.;
DATALINES;
05Jan2018 ENG1 10
16Feb2018 Bio2 15
09Apr2018 Che1 10
15Jan2018 Bio1 11
11MAY2018 Eng2 15
09Mar2018 Phy2 11
20Feb2018 Che1 15
;
RUN;

PROC PRINT DATA=Year18_19 NOOBS;
RUN;

DATA Year17_18;
INPUT Date1 Course_ID $4. age 3.;
INFORMAT Date1 Date9.;
FORMAT Date1 Date9.;
DATALINES;
05Jan2018 ENG1 10
16Jan2017 Bio2 15
09Feb2017 Che1 10
15Mar2018 Bio1 11
11MAY2017 Eng2 15
22Apr2017 Phy2 11
20Feb2018 Che1 15
;
RUN;

PROC PRINT DATA=Year17_18 NOOBS;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi,&lt;BR /&gt;My Fiscal Year goes from March 01 to February 30. When I am in the month of May now, I want to pull all the data for this fiscal year (from dataset Year18_19 above) UNTIL last month.&lt;BR /&gt;and I want the system to calculate that from sysdate.&lt;/P&gt;
&lt;P&gt;So for this fiscal year code should return the following observations from dataset Year18_19:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Date1 Course_ID age&lt;/STRONG&gt;&lt;BR /&gt;09Apr2018 Che1 10&lt;BR /&gt;11MAY2018 Eng2 15&lt;BR /&gt;09Mar2018 Phy2 11&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Now I want to do the same for the last Fiscal year (Year17_18) which will return:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Date1 Course_ID age&lt;/STRONG&gt;&lt;BR /&gt;05Jan2018 ENG1 10&lt;BR /&gt;11MAY2017 Eng2 15&lt;BR /&gt;22Apr2017 Phy2 11&lt;BR /&gt;20Feb2018 Che1 15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to follow the following code to accomplish it, but I really can't get anything out of it. I will really appreciate any help on this.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let previous_month = %sysfunc(
intnx( MONTH , %sysfunc( today() ) , -1)
, yymmN6.);



%MACRO fy (date , start=7);
year(&amp;amp;date) + (month(&amp;amp;date) ge &amp;amp;start and &amp;amp;start ne 1)
%MEND;



DATA try_FY;
this_date = date();
FiscalYear = %FY( this_date , start = 3 );
PUTLOG FiscalYear = Txn_Date=date9.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 02:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462546#M117779</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-05-16T02:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Coding with multiple Fiscal Year Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462772#M117857</link>
      <description>&lt;P&gt;This should help you:&amp;nbsp; &lt;A href="http://www2.sas.com/proceedings/sugi25/25/cc/25p084.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi25/25/cc/25p084.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 17:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462772#M117857</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-05-16T17:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Coding with multiple Fiscal Year Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462809#M117859</link>
      <description>&lt;P&gt;If your fiscal year began in January, you could just use the YEAR function to get fiscal year, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; fiscal_year=year(date1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since your fiscal year begins in March you could do the following: (1) get the closest march preceding DATE1, and (2) get the calendar year of that march, and call it fiscal year, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set year17_18 year18_19;
  fyear=year(intnx('year.3',date1,0,'B'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INTNX functions says to add a some units&amp;nbsp;called "year.3"&amp;nbsp; (years beginning in March) to DATE1.&amp;nbsp; The 0 as third argument says to add zero such year, and the 'B' say to aligned the resulting date to the beginning of the year.3 time span.&amp;nbsp; So Dec20, 2017 --&amp;gt; March 1, 2017&amp;nbsp; --&amp;gt; FYEAR=2017.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've labeled fiscal years using the calendar year of their first month.&amp;nbsp; So fiscal year March 2017-Feb 2018 is 2017.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 19:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-with-multiple-Fiscal-Year-Data/m-p/462809#M117859</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-16T19:13:52Z</dc:date>
    </item>
  </channel>
</rss>

