<?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: Dynamic filtering of data until last month of every year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463423#M118066</link>
    <description>&lt;P&gt;What is the output your expecting? You don't need %SYSFUNC in your code.&lt;/P&gt;</description>
    <pubDate>Fri, 18 May 2018 19:31:35 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-05-18T19:31:35Z</dc:date>
    <item>
      <title>Dynamic filtering of data until last month of every year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463420#M118064</link>
      <description>&lt;P&gt;Here is what my data situation and what I want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My fiscal year goes from March 1 to end of February. At any given day (let's say today) I have my current fiscal year data until today (Mar 01 2018 - May 19 2018) and data from last 2 full fiscal year.&lt;/P&gt;
&lt;P&gt;For example today I have:&lt;BR /&gt;FiscalYear 2018-2019: Mar 01 2018 - May 19 2019&lt;BR /&gt;Fiscal Year 2017-2018: Mar 01 2017 - Feb 28 2018&lt;BR /&gt;Fiscal Year 2016-2017: Mar 01 2016 - Feb 28 2017&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;WHAT I WANT:&lt;BR /&gt;-------------------&lt;/P&gt;
&lt;P&gt;Filter the data until the end of last month (in my case April of 2018-2019 Fiscal Year) and I want the code to determine that from system date.&lt;BR /&gt;Filter the data from each last 2 fiscal year until the end of April of each year. In my example it will be April 2017 &amp;amp; April 2016.&lt;BR /&gt;Every month when I will run my code, I don't want to change my Year/Fiscal year manually on my code.&lt;/P&gt;
&lt;P&gt;My output table should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;16Mar2016 Bio2&lt;/P&gt;
&lt;P&gt;01Mar2018 Eng1&lt;BR /&gt;15Mar2018 Bio1&lt;BR /&gt;27Apr2018 Bio1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HERE IS MY Example DATA&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA have;&lt;BR /&gt;INPUT Date Course_ID $4.;&lt;BR /&gt;INFORMAT Date Date9.;&lt;BR /&gt;FORMAT Date Date9.;&lt;BR /&gt;DATALINES;&lt;BR /&gt;05Jan2018 ENG1&lt;BR /&gt;16Aug2017 Bio2&lt;BR /&gt;11MAY2015 Eng2&lt;BR /&gt;28Feb2018 Geo2&lt;/P&gt;
&lt;P&gt;16Mar2016 Bio2&lt;/P&gt;
&lt;P&gt;01Mar2018 Eng1&lt;BR /&gt;09Feb2017 Che1&lt;BR /&gt;19Jan2015 Phy2&lt;BR /&gt;15Mar2018 Bio1&lt;BR /&gt;12Mar2015 Phy2&lt;BR /&gt;19May2018 Che1&lt;BR /&gt;27Apr2018 Bio1&lt;BR /&gt;;&lt;BR /&gt;PROC PRINT NOOBS;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 19:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463420#M118064</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-05-19T19:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic filtering of data until last month of every year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463423#M118066</link>
      <description>&lt;P&gt;What is the output your expecting? You don't need %SYSFUNC in your code.&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 19:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463423#M118066</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-18T19:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic filtering of data until last month of every year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463428#M118069</link>
      <description>&lt;P&gt;Shouldn’t your condition be the opposite?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It’s hard to follow your code an logic, for me at least, but I think you could just filter on the month? Then all the relevant months are included and you can ignore the concept of days or years.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where month(date)  &amp;lt;= month(intnx(‘month’, today(), -1));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 19:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463428#M118069</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-18T19:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic filtering of data until last month of every year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463456#M118077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I want to write code which will dynamically filter the data until the last date of previous month of every year in the database ('date' field in this case) at any given month&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is my input data&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
INPUT Date Course_ID $4.;
INFORMAT Date Date9.;
FORMAT Date Date9.;
DATALINES;
05Jan2018 ENG1
16Jan2017 Bio2
09Dec2016 Che1
15Jan2018 Bio1
11MAY2015 Eng2
12Mar2016 Phy2
20May2018 Che1
;
PROC PRINT NOOBS;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;I have written the follow code, but I can't make it work. can someone please help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want;
SET have;
Y0_FYb=YEAR(intnx('YEAR.4',date,0));
Y0_FYe=YEAR(intnx('YEAR.4',date,0,'e'));

Y0_fromdate=intnx('year.4',date,0,'b');
Y0_todate=intnx('MONTH',date,-1,'e');

Y1P_FY=YEAR(intnx('YEAR.4',date,0));
Y1P_fromdate=intnx('year.4',date,0,'b');
Y1P_todate=intnx('MONTH',date,-1,'e');

Rep_ToMonth=intnx('MONTH', date , -1, 'e');
fy2 = COMPRESS(Y0_FYb||"-"||Y0_FYe);
FORMAT Y0_fromdate
Y0_todate Rep_ToMonth date date9.;
PROC PRINT NOOBS;
RUN;

DATA Final;
SET want;
WHERE Rep_ToMOnth &amp;gt;= intnx('MONTH', %SYSFUNC(today()), -1, 'e');
RUN;
PROC PRINT NOOBS;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can't make it&amp;nbsp;work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VERY seldom does %sysfunc belong in a data step and almost never in an "open code", not part of code inside a %macro / %mend; definition.&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 22:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463456#M118077</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-18T22:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic filtering of data until last month of every year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463563#M118116</link>
      <description>Sorry my post did not make much sense I just realized. Here is what my data situation and what I want. Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;My fiscal year goes from March 1 to end of February. At any given day (let's say today) I have my current fiscal year data until today (Mar 01 2018 - May 19 2018) and data from last 2 full fiscal year. &lt;BR /&gt;&lt;BR /&gt;For example today I have:&lt;BR /&gt;FiscalYear 2018-2019: Mar 01 2018 - May 19 2019&lt;BR /&gt;Fiscal Year 2017-2018: Mar 01 2017 - Feb 28 2018&lt;BR /&gt;Fiscal Year 2016-2017: Mar 01 2016 - Feb 28 2017&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;WHAT I WANT:&lt;BR /&gt;-------------------&lt;BR /&gt;&lt;BR /&gt;Filter the data until the end of last month (in my case April of 2018-2019 Fiscal Year) and I want the code to determine that from system date.&lt;BR /&gt;Filter the data from each last 2 fiscal year until the end of April of each year. In my example it will be April 2017 &amp;amp; April 2016.&lt;BR /&gt;Every month when I will run my code, I don't want to change my Year/Fiscal year manually on my code.&lt;BR /&gt;&lt;BR /&gt;My output table should look like this:&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;16Mar2016 Bio2&lt;BR /&gt;&lt;BR /&gt;01Mar2018 Eng1&lt;BR /&gt;15Mar2018 Bio1&lt;BR /&gt;27Apr2018 Bio1&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;HERE IS MY Example DATA&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA have;&lt;BR /&gt;INPUT Date Course_ID $4.;&lt;BR /&gt;INFORMAT Date Date9.;&lt;BR /&gt;FORMAT Date Date9.;&lt;BR /&gt;DATALINES;&lt;BR /&gt;05Jan2018 ENG1&lt;BR /&gt;16Aug2017 Bio2&lt;BR /&gt;11MAY2015 Eng2&lt;BR /&gt;28Feb2018 Geo2&lt;BR /&gt;&lt;BR /&gt;16Mar2016 Bio2&lt;BR /&gt;&lt;BR /&gt;01Mar2018 Eng1&lt;BR /&gt;09Feb2017 Che1&lt;BR /&gt;19Jan2015 Phy2&lt;BR /&gt;15Mar2018 Bio1&lt;BR /&gt;12Mar2015 Phy2&lt;BR /&gt;19May2018 Che1&lt;BR /&gt;27Apr2018 Bio1&lt;BR /&gt;;&lt;BR /&gt;PROC PRINT NOOBS;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 19 May 2018 19:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-filtering-of-data-until-last-month-of-every-year/m-p/463563#M118116</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-05-19T19:07:04Z</dc:date>
    </item>
  </channel>
</rss>

