<?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: Extract using date between in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635597#M188743</link>
    <description>&lt;P&gt;I don't see any example data?&lt;/P&gt;</description>
    <pubDate>Sun, 29 Mar 2020 09:15:47 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-03-29T09:15:47Z</dc:date>
    <item>
      <title>Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635594#M188740</link>
      <description>&lt;P&gt;I would like to know how to filter the records based on two different dates. Assume I've a variables called &lt;STRONG&gt;Valid_from&lt;/STRONG&gt; and it has&amp;nbsp; a value &lt;STRONG&gt;20200323T000000&lt;/STRONG&gt; and other variable called &lt;STRONG&gt;Valid_to &lt;/STRONG&gt;and it has a value &lt;STRONG&gt;99991231T235959 &lt;/STRONG&gt;and also other few variables. Formats and informats for Valid_from and Valid_to is &lt;FONT face="Courier New" size="3" color="#008080"&gt;B8601DT.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to select the records only if the current datetime is between&amp;nbsp; Valid_from and Valid_to&lt;STRONG&gt;. &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May be something like below but I'm not sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; VALID_FROM &amp;lt;= DATETIME() &amp;lt;= VALID_TO;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I do not have&amp;nbsp;SAS EG at the Moment. So appericiate if someone confirm if the above condition works, otherwise please tell me&amp;nbsp;the correct one.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 08:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635594#M188740</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2020-03-29T08:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635595#M188741</link>
      <description>&lt;P&gt;I can confirm that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   VALID_FROM = '23mar2020:00:00:00'dt;
   VALID_TO   = '31dec9999:23:59:59'dt;
   if VALID_FROM &amp;lt;= DATETIME() &amp;lt;= VALID_TO then put 'It works'; 
   format VALID_FROM VALID_TO B8601DT.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;It works&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 Mar 2020 09:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635595#M188741</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-29T09:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635596#M188742</link>
      <description>&lt;P&gt;Is it possible for you to show me with my example data and the format which I applied and then applying the filters?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 09:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635596#M188742</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2020-03-29T09:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635597#M188743</link>
      <description>&lt;P&gt;I don't see any example data?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 09:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635597#M188743</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-29T09:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635601#M188744</link>
      <description>I gave the example values and the format I used in the initial post&lt;BR /&gt;</description>
      <pubDate>Sun, 29 Mar 2020 09:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635601#M188744</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2020-03-29T09:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635604#M188745</link>
      <description>&lt;P&gt;Please look at my code again. I use the variables, values and format exactly as you describe.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 09:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635604#M188745</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-29T09:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635637#M188757</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible for you to show me with my example data and the format which I applied and then applying the filters?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You did not show example data, only example values. Example data = a data step that creates a dataset.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 14:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635637#M188757</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-29T14:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635674#M188774</link>
      <description>&lt;P&gt;Here are instructions on how to provide sample data as a data step:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 17:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635674#M188774</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-29T17:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extract using date between</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635695#M188783</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you might know the format applied to a variable doesn't change its internal value so the format is of no relevance here.&lt;/P&gt;
&lt;P&gt;Furthermore the variable names indicate that you're dealing with an SCD Type2 structure likely loaded using the DIS SCD Type 2 transformation. If using Datetime() in the selection then you're only after the current record and if so then below two clauses would also work as an alternative:&lt;/P&gt;
&lt;P&gt;1. where change_current_ind='Y'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. datetime() &amp;lt; valid_to_dttm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 2nd option will work because the SCD Type 2 loader will expire all not current rows based on datetime() when loading; and all current rows will have a valid_to_date somewhere far in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 01:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-using-date-between/m-p/635695#M188783</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-30T01:29:24Z</dc:date>
    </item>
  </channel>
</rss>

