<?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: Filter dataset by for March 2024 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filter-dataset-by-for-March-2024/m-p/926336#M364538</link>
    <description>&lt;P&gt;Your code would work if&amp;nbsp;&lt;SPAN&gt;c_EFF_DT was an actual SAS date value. But it is not a SAS date, it is a SAS date/time value. How do I know? Because it has been assigned a date/time format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So to do the filtering, you have to use date/time values&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where "01Mar2024:00:00:00"dt &amp;lt;= c_EFF_DT &amp;lt;= "31Mar2024:00:00:00"dt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or even simpler, convert c_eff_dt to a date value&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; where "01Mar2024"d &amp;lt;= datepart(c_EFF_DT) &amp;lt;= "31Mar2024"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or if you are going to be doing this repeatedly for future months, and you don't want to have to figure out what the last day of each month is and then type that into the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where month(datepart(c_eff_dt))=3 and year(datepart(c_eff_dt))=2024;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where '01MAR2024'd &amp;lt;= datepart(c_eff_dt) &amp;lt; '01APR2024'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the change from &amp;lt;= to &amp;lt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like the last one best, less typing, no need to mentally figure out what the last day of the month is&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2024 16:44:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-04-29T16:44:02Z</dc:date>
    <item>
      <title>Filter dataset by for March 2024</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-dataset-by-for-March-2024/m-p/926335#M364537</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset called test_dataset and want to only keep accounts where the c_EFF_DT variable is in March 2024 (so in example below, only the account with 02MAR2024 would remain). My code below isn't filtering correctly, so can someone help me to correct it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test_output;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set test_dataset;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;where "01Mar2024"d &amp;lt;= c_EFF_DT &amp;lt;= "31Mar2024"d;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Justin9_0-1714408008865.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96001iE2C75480657873FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Justin9_0-1714408008865.png" alt="Justin9_0-1714408008865.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Justin9_1-1714408032148.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96002iD4F97A229EC7AE8B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Justin9_1-1714408032148.png" alt="Justin9_1-1714408032148.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 16:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-dataset-by-for-March-2024/m-p/926335#M364537</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2024-04-29T16:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset by for March 2024</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-dataset-by-for-March-2024/m-p/926336#M364538</link>
      <description>&lt;P&gt;Your code would work if&amp;nbsp;&lt;SPAN&gt;c_EFF_DT was an actual SAS date value. But it is not a SAS date, it is a SAS date/time value. How do I know? Because it has been assigned a date/time format.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So to do the filtering, you have to use date/time values&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where "01Mar2024:00:00:00"dt &amp;lt;= c_EFF_DT &amp;lt;= "31Mar2024:00:00:00"dt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;or even simpler, convert c_eff_dt to a date value&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; where "01Mar2024"d &amp;lt;= datepart(c_EFF_DT) &amp;lt;= "31Mar2024"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or if you are going to be doing this repeatedly for future months, and you don't want to have to figure out what the last day of each month is and then type that into the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where month(datepart(c_eff_dt))=3 and year(datepart(c_eff_dt))=2024;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where '01MAR2024'd &amp;lt;= datepart(c_eff_dt) &amp;lt; '01APR2024'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the change from &amp;lt;= to &amp;lt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like the last one best, less typing, no need to mentally figure out what the last day of the month is&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 16:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-dataset-by-for-March-2024/m-p/926336#M364538</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-29T16:44:02Z</dc:date>
    </item>
  </channel>
</rss>

