<?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: Dates Filtering in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530222#M144975</link>
    <description>&lt;P&gt;&lt;EM&gt;Extract the Date from Datetime using the datepart() function.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '01APR2018'D &amp;lt;= DATEPART(DISCH_DT) &amp;lt;= '30JUN2018'D THEN output FY1819Q1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 25 Jan 2019 21:02:57 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2019-01-25T21:02:57Z</dc:date>
    <item>
      <title>Dates Filtering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530218#M144972</link>
      <description>&lt;P&gt;&lt;EM&gt;04APR2018:00:00:00&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I have dates in the above format in the sas dataset that is datetime 20 but my code below does not extract the records for Q1 which should be any records that fall between and are equal 1st April 2018 to 30 June 2018&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please advise&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data FY1819Q1;&lt;BR /&gt;set EVT.SP440_FY2018Q2;&lt;BR /&gt;if '01APR2018'D &amp;lt;= DISCH_DT &amp;lt;= '30JUN2018'D THEN output FY1819Q1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 20:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530218#M144972</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-01-25T20:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dates Filtering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530222#M144975</link>
      <description>&lt;P&gt;&lt;EM&gt;Extract the Date from Datetime using the datepart() function.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if '01APR2018'D &amp;lt;= DATEPART(DISCH_DT) &amp;lt;= '30JUN2018'D THEN output FY1819Q1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 21:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530222#M144975</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-25T21:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dates Filtering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530223#M144976</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;EM&gt;04APR2018:00:00:00&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I have dates in the above format in the sas dataset that is datetime 20 but my code below does not extract the records for Q1 which should be any records that fall between and are equal 1st April 2018 to 30 June 2018&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Please advise&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;data FY1819Q1;&lt;BR /&gt;set EVT.SP440_FY2018Q2;&lt;BR /&gt;if '01APR2018'D &amp;lt;= DISCH_DT &amp;lt;= '30JUN2018'D THEN output FY1819Q1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your example value show time components and would be a SAS DATETIME value, not a date. When you want to use only the DATE portion of such a variable the function Datepart would be used on the value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;data FY1819Q1;
set EVT.SP440_FY2018Q2;
if '01APR2018'D &amp;lt;= datepart (DISCH_DT) &amp;lt;= '30JUN2018'D THEN output FY1819Q1;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 21:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-Filtering/m-p/530223#M144976</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-25T21:04:37Z</dc:date>
    </item>
  </channel>
</rss>

