<?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 SAS dataset using a where between two dates in data step between in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142808#M37993</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi jwillis&lt;/P&gt;&lt;P&gt;I tried chnanging the code to 18 position. still I am not able to see the output. Looks like once the data is in date format, it is not allowing 'WHERE' Statement to filter based upon the date.&lt;/P&gt;&lt;P&gt;I have to change it to date from varchar to get the right number of records when I filter the data based upon date. However converting to date and filtering the dates between two given dates is actully not getting any outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Jul 2014 19:09:14 GMT</pubDate>
    <dc:creator>ahsyed</dc:creator>
    <dc:date>2014-07-30T19:09:14Z</dc:date>
    <item>
      <title>Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142804#M37989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have a dataset which needs to be filtered based upon two dates from and to. I am using the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ABC (WHERE=(Date BETWEEN '01OCT2013:00:00:00'd AND '31DEC2013:00:00:00'd));&lt;/P&gt;&lt;P&gt;set Libname.ABC&lt;/P&gt;&lt;P&gt;But this is not working . Any help appraciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 17:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142804#M37989</guid>
      <dc:creator>ahsyed</dc:creator>
      <dc:date>2014-07-30T17:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142805#M37990</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ABC 
 (WHERE=(Date&amp;gt;='01OCT2013:00:00:00'dt 
     AND Date&amp;lt;='31DEC2013:00:00:00'dt)
 );
 set libname.ABC;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use the BETWEEN keyword:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ABC 
 (WHERE=(Date BETWEEN '01OCT2013:00:00:00'dt 
     AND '31DEC2013:00:00:00'dt)
 );
 set libname.ABC;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you place the WHERE option on the data set in the DATA keyword, it limits the output to just the filtered values, but the DATA step will read all of the values in the data on the SET statement. To limit the records you &lt;STRONG&gt;read&lt;/STRONG&gt;, place the filter on the SET statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ABC;
 set libname.ABC (WHERE=
   (Date BETWEEN '01OCT2013:00:00:00'dt 
      AND '31DEC2013:00:00:00'dt)
  );
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Nov 2020 17:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142805#M37990</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2020-11-05T17:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142806#M37991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the solution. The Code works however there is no data coming out for the datastep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as a background for the date: I am getting the date from&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date = input(Substr(CC,1,10),anydtdtm20.);&amp;nbsp; *(CC is the date with string);&lt;/P&gt;&lt;P&gt;FORMAT Date datetime19.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Though it is showing date cloumn without filter, when I am filtering the dataset upon date to be between 01OCT2013'd AND '31DEC2013'd, it is not shouing up.[ Any Clue ]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 17:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142806#M37991</guid>
      <dc:creator>ahsyed</dc:creator>
      <dc:date>2014-07-30T17:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142807#M37992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ahsyed,&lt;/P&gt;&lt;P&gt;I'm responding because I have never seen your style of coding.&amp;nbsp; It is intriguing. Could your issue be that your date is "datetime19." and your where values are only 18 positions long? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;01OCT2013:00:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've seen a where in the set statement and I've seen a where after the set statement but until now, I have never seen a where in the Data statement.&amp;nbsp; Cool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 17:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142807#M37992</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-30T17:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142808#M37993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi jwillis&lt;/P&gt;&lt;P&gt;I tried chnanging the code to 18 position. still I am not able to see the output. Looks like once the data is in date format, it is not allowing 'WHERE' Statement to filter based upon the date.&lt;/P&gt;&lt;P&gt;I have to change it to date from varchar to get the right number of records when I filter the data based upon date. However converting to date and filtering the dates between two given dates is actully not getting any outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 19:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142808#M37993</guid>
      <dc:creator>ahsyed</dc:creator>
      <dc:date>2014-07-30T19:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142809#M37994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahsyed,&lt;/P&gt;&lt;P&gt;I am still intrigued.&amp;nbsp; I have written date selection algorithm's that also failed.&amp;nbsp; Inevitably the issue cause was between character representations of dates; blanks; SAS date numerics; and format settings.&amp;nbsp; Can you post ten examples of your date values and what you expect to retreive from the ten rows when your where statement is working correctly?&amp;nbsp; Your code is pulling 10 characters with a substring then formatting the 10 characters as anydttm20.&amp;nbsp; I've never seen anydttm20. :smileyblush: and I want to&amp;nbsp; play around and learn more about what you are doing. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 19:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142809#M37994</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-30T19:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142810#M37995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this, just added dt instead of d in the syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ABC (WHERE=(Date&amp;gt;='01OCT2013:00:00:00'&lt;STRONG&gt;dt&lt;/STRONG&gt; AND Date&amp;lt;='31DEC2013:00:00:00'&lt;STRONG&gt;dt&lt;/STRONG&gt;));&lt;/P&gt;&lt;P&gt;set Libname.ABC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 19:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142810#M37995</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-30T19:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter SAS dataset using a where between two dates in data step between</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142811#M37996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="j-status-levels"&gt;&lt;IMG alt="Apprentice" class="jiveImage" src="https://communities.sas.com/5.0.2/images/status/statusicon-49.gif" title="Apprentice" /&gt; &lt;/SPAN&gt;&lt;SPAN class="j-post-author "&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="813022" data-username="stat%40sas" href="https://communities.sas.com/people/stat@sas" id="jive-81302222128859320522186"&gt;stat@sas&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Bingo! It worked. As per your&amp;nbsp; suggestion changed from &lt;STRONG&gt;d&lt;/STRONG&gt; to &lt;STRONG&gt;dt.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thanks all this fixes my issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;ahsyed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 19:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-SAS-dataset-using-a-where-between-two-dates-in-data-step/m-p/142811#M37996</guid>
      <dc:creator>ahsyed</dc:creator>
      <dc:date>2014-07-30T19:42:23Z</dc:date>
    </item>
  </channel>
</rss>

