<?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: How to filter date old column from system date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552450#M153574</link>
    <description>&lt;P&gt;From what you initially posted, it appears that&amp;nbsp;&lt;SPAN&gt;dwh_isrt_dt is a&amp;nbsp;&lt;/SPAN&gt;datetime value, not a date value. It counts seconds, not days.&lt;/P&gt;
&lt;P&gt;Note that &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1lfp83m4yht68n1luxn5tnmuhp3.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;trunc()&lt;/A&gt;&amp;nbsp;is a function that works on the binary structure of number (Maxim 1: Read the -linked- Documentation).&lt;/P&gt;
&lt;P&gt;To extract the date from a datetime, use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0rttbu7w62xgzn1damccyuwpld8.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;datepart()&lt;/A&gt; function.&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0hm9egy8s7mokn1mz0yxng80ax5.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;today()&lt;/A&gt; function has no arguments, it always delivers today's date as a SAS date value (days from 1960-01-01).&lt;/P&gt;
&lt;P&gt;To calculate yesterday's date, simply use&lt;/P&gt;
&lt;PRE&gt;today() - 1&lt;/PRE&gt;</description>
    <pubDate>Fri, 19 Apr 2019 14:23:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-04-19T14:23:42Z</dc:date>
    <item>
      <title>How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552426#M153563</link>
      <description>&lt;DIV&gt;&lt;DIV class="ia-splitter"&gt;&lt;DIV class=" aui-page-panel"&gt;&lt;DIV class="page view"&gt;&lt;DIV class="wiki-content"&gt;&lt;DIV class="table-wrap"&gt;Hello Experts,&lt;/DIV&gt;&lt;DIV class="table-wrap"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="table-wrap"&gt;I saw a table with column declared in 8 numeric format datetime10.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;if I want to run the query in SAS to put the column with a day old from today.&amp;nbsp; &amp;nbsp;How do I do that?&lt;/P&gt;&lt;P&gt;Table aaa:&lt;/P&gt;&lt;P&gt;receipt_number&amp;nbsp; &amp;nbsp; &amp;nbsp;dwh_isrt_dt&lt;/P&gt;&lt;P&gt;MSC123353&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07MAY2015:10:31:24&lt;/P&gt;&lt;P&gt;MSC529890&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09JUL2017:08:09:12&lt;/P&gt;&lt;P&gt;MSC524141&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 28AUG2017:08:09:12&lt;/P&gt;&lt;P&gt;MSC258890&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 09JUL2018:08:09:12&lt;/P&gt;&lt;P&gt;EAC129098&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 17APR2019:21:34:12&lt;/P&gt;&lt;P&gt;EAC129148&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 17APR2019:21:34:12&lt;/P&gt;&lt;P&gt;EAC349098&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18APR2019:21:34:12&lt;/P&gt;&lt;P&gt;EAC234698&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18APR2019:21:34:12&lt;/P&gt;&lt;P&gt;EAC224698&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19APR2019:01:33:02&lt;/P&gt;&lt;P&gt;EAC587698&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19APR2019:21:34:12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't find trunc(sysdate -1) in SAS.&amp;nbsp; I have tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;select&amp;nbsp;DISTINCT&amp;nbsp;a.receipt_number, sbmtd_dt_id from aaa&lt;BR /&gt;where today(sbmtd_dt_id - 1);&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;select&amp;nbsp;DISTINCT&amp;nbsp;a.receipt_number, sbmtd_dt_id from aaa&lt;BR /&gt;having sbmtd_dt_id = max(sbmtd_dt_id - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;both queries ares running nonestop w/o result,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Oracle I can run&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;SELECT DISTINCT&amp;nbsp;a.receipt_number, a.sbmtd_dt_id&lt;BR /&gt;FROM APPLICATION_CDIM a&lt;BR /&gt;WHERE (trunc(a.sbmtd_dt_id) = trunc(sysdate - 1) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;even I try to find the last record of the table by using 'max(sbmtd_dt_id)':&lt;/P&gt;&lt;P&gt;select receipt_number, sbmt_dt_id from table aaa where max(sbmtd_dt_id);&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the query doesn't work.&amp;nbsp; Not sure I am doing a right thing here.&amp;nbsp; Wondering for Proc SQL code to generate the select with first couple rows and last 5 rows from the millions records?&amp;nbsp; Also, &lt;SPAN&gt;can you please suggest the best way to go about &lt;/SPAN&gt;pull the column fetch in a day, 2, 3 days old?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bach-Nga&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 13:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552426#M153563</guid>
      <dc:creator>pepevo</dc:creator>
      <dc:date>2019-04-19T13:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552428#M153564</link>
      <description>&lt;DIV&gt;
&lt;DIV class="ia-splitter"&gt;
&lt;DIV class=" aui-page-panel"&gt;
&lt;DIV class="page view"&gt;
&lt;DIV class="wiki-content"&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="table-wrap"&gt;I saw a table with column declared in 8 numeric format datetime10.&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;if I want to run the query in SAS to put the column with a day old from today.&amp;nbsp; &amp;nbsp;How do I do that?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Explain this in more detail. Show us the output you want.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 13:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552428#M153564</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-19T13:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552444#M153571</link>
      <description>&lt;P&gt;the query is running for awhile and give me no result but from log I see:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;PROC SQL;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;SELECT a.receipt_number, bcf.actn_dt_in_id&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;FROM EXISDRDM.APPLICATION_CDIM a&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;INNER JOIN EXISDRDM.BNFT_CURR_FACT bcf&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;on bcf.application_id = a.application_id&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;INNER JOIN EXISDRDM.BNFT_HIST_ACTN_LDIM hist&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;ON bcf.BNFT_HIST_ACTN_ID = hist.BNFT_HIST_ACTN_ID&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;WHERE bcf.actn_dt_in_id = today(bcf.actn_dt_in_id - 1)&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;;&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Function TODAY requires at most 0 argument(s). The extra one(s) will be ignored.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: No rows were selected.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 1:36.65&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 4:59.46&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;the other for pulling the last record, still no result but according to the log I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;proc sql ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;select a.receipt_number, a.dwh_isrt_dt&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;FROM EBI3CONS.history a&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;HAVING a.dwh_isrt_dt = max(a.dwh_isrt_dt);&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The query requires remerging summary statistics back with the original data.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: There were 1354550678 observations read from the data set EBI3CONS.HISTORY.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;ORACLE: Pipelined I/O thread did not timely terminate&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 10:45.26&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 18:15.75&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;on another hands, I run the query with a day old (not sure it's right) and I get a result but in year 2015.&amp;nbsp; It should give me none if a day old not match with receipt_number, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt;&amp;nbsp;a.receipt_number, a.dwh_isrt_dt&amp;nbsp;&lt;STRONG&gt;FROM&lt;/STRONG&gt; EBI3CONS.history a &lt;STRONG&gt;WHERE&lt;/STRONG&gt; a.receipt_number ='MSC0416310095' &lt;STRONG&gt;AND&lt;/STRONG&gt; today(a.dwh_irt_dt -1);&lt;/P&gt;&lt;P&gt;&lt;SPAN class="confluence-embedded-file-wrapper"&gt;&lt;IMG src="https://sens3.leidos.com/confluence/download/attachments/15631183/image2019-4-18_14-39-54.png?version=1&amp;amp;modificationDate=1555612794270&amp;amp;api=v2" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;v/r,&lt;/P&gt;&lt;P&gt;Bach-Nga&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 14:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552444#M153571</guid>
      <dc:creator>pepevo</dc:creator>
      <dc:date>2019-04-19T14:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552449#M153573</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select&amp;nbsp;DISTINCT&amp;nbsp;a.receipt_number&amp;nbsp; &amp;nbsp;from aaa&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where&amp;nbsp; &amp;nbsp;datepart(&amp;nbsp;dwh_isrt_dt)= today()-1 ;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 14:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552449#M153573</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-19T14:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552450#M153574</link>
      <description>&lt;P&gt;From what you initially posted, it appears that&amp;nbsp;&lt;SPAN&gt;dwh_isrt_dt is a&amp;nbsp;&lt;/SPAN&gt;datetime value, not a date value. It counts seconds, not days.&lt;/P&gt;
&lt;P&gt;Note that &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1lfp83m4yht68n1luxn5tnmuhp3.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;trunc()&lt;/A&gt;&amp;nbsp;is a function that works on the binary structure of number (Maxim 1: Read the -linked- Documentation).&lt;/P&gt;
&lt;P&gt;To extract the date from a datetime, use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0rttbu7w62xgzn1damccyuwpld8.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;datepart()&lt;/A&gt; function.&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0hm9egy8s7mokn1mz0yxng80ax5.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;today()&lt;/A&gt; function has no arguments, it always delivers today's date as a SAS date value (days from 1960-01-01).&lt;/P&gt;
&lt;P&gt;To calculate yesterday's date, simply use&lt;/P&gt;
&lt;PRE&gt;today() - 1&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Apr 2019 14:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552450#M153574</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-19T14:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter date old column from system date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552467#M153580</link>
      <description>&lt;P&gt;thank you all for helping with sysdate -1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried datepart (column -1) and today (column -1).&amp;nbsp; Thank you for showing me depart(column) = today() -1 &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;P&gt;thank you again and have happy Easter's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;v/r,&lt;/P&gt;&lt;P&gt;Bach-Nga&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 15:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-filter-date-old-column-from-system-date/m-p/552467#M153580</guid>
      <dc:creator>pepevo</dc:creator>
      <dc:date>2019-04-19T15:27:36Z</dc:date>
    </item>
  </channel>
</rss>

