<?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: Identifying Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443110#M110835</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your original value, such as 2014-06-26 14:31:24.0000000, a character variable.&amp;nbsp; Or is it just what the raw data looks like?&lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 00:42:25 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-03-07T00:42:25Z</dc:date>
    <item>
      <title>Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443106#M110832</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm having a tough time selecting my data year. I want to include only those years that are greater than 2014.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My original_date variable is of this format:&amp;nbsp;&lt;/SPAN&gt;2014-06-26 14:31:24.0000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data new;&lt;BR /&gt;set old;&lt;/P&gt;&lt;P&gt;original_date_sas= input(original_date,anydtdte10.);&lt;/P&gt;&lt;P&gt;format original_date_sas mmddyy10.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fiscal_year = intnx('YEAR.04',original_date_sas,0); /*fiscal year starts april 1 (month 4) */&lt;BR /&gt;format fiscal_year year.;&lt;/P&gt;&lt;P&gt;if fiscal_year GE 2014; /*anything starting from 2014 */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is "&lt;SPAN&gt;if fiscal_year GE 2014; " doesn't work!&amp;nbsp; It still keeps records that are earlyer than 2014. I have tried COMPRESS and&amp;nbsp; LEFT when creating original_date_sas,&amp;nbsp; and I put "2014"d., when specify the year but doesn't work. Any suggestions?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443106#M110832</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-03-07T00:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443110#M110835</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your original value, such as 2014-06-26 14:31:24.0000000, a character variable.&amp;nbsp; Or is it just what the raw data looks like?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443110#M110835</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-07T00:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443111#M110836</link>
      <description>&lt;P&gt;That's what the raw data are, and yes, SAS considers it a character variable.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443111#M110836</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-03-07T00:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443129#M110840</link>
      <description>&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Don't use anydtdte. format.&amp;nbsp; Use yymmdd10., which will read the first 10 characters of ORIGINAL_DATE.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;INTNX produces a DATE, not a YEAR, so you need to use the YEAR function applied to the date:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
  set old;
  original_date_sas= input(original_date,yymmdd10.);
  format original_date_sas date9.;

  fiscal_year=year(intnx('year.04',original_date_sas,0));

  if fiscal_year GE 2014; /*anything starting from 2014 */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INTNX function adds zero year.04 time spans to the date, and &lt;EM&gt;&lt;STRONG&gt;then aligns the resulting date to the beginning of the span&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; So all the dates from 01apr2014 through 31mar2015 generate 01apr2014.&amp;nbsp; The year function gets 2014, as you desire.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that in the US, fiscal years defined as JAN-DEC&amp;nbsp;&amp;nbsp; through JUN-MAY usually are identified with the year of the beginning month.&amp;nbsp; And fiscal years of JUL-JUN through DEC-NOV would be identified with the ending month.&amp;nbsp; I.e. in general whichever calendar year possesses the majority of months in the fiscal year, is used as the identifier.&amp;nbsp; That's how the IRS identifies tax years.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 01:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443129#M110840</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-07T01:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443155#M110845</link>
      <description>&lt;P&gt;Even thought fiscal_date is displayed as a year (format), it is actually still a SAS date value (i.e, a count of the number of days since 01Jan1960).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your&amp;nbsp;SAS date value &lt;STRONG&gt;2014&lt;/STRONG&gt; is actually &lt;STRONG&gt;07July1965&lt;/STRONG&gt;, which means most if not all of your data will pass the test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your filter should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if fiscal_year GE "01Jan2014"d; /*anything starting from 2014 */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 02:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/443155#M110845</guid>
      <dc:creator>AndrewHowell</dc:creator>
      <dc:date>2018-03-07T02:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/445566#M111675</link>
      <description>Thank you for the thorough explanation!</description>
      <pubDate>Wed, 14 Mar 2018 17:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/445566#M111675</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-03-14T17:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/445567#M111676</link>
      <description>This also works!</description>
      <pubDate>Wed, 14 Mar 2018 17:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-Year/m-p/445567#M111676</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-03-14T17:57:59Z</dc:date>
    </item>
  </channel>
</rss>

