<?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: SAS not using Truncate function but Oracle showing Truncate funcation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464247#M118354</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165195"&gt;@Ahsan&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It's most likely not Oracle but the SAS Access to Oracle engine which adds this truncate to the code.&lt;/P&gt;
&lt;P&gt;You can see what SAS sends to Oracle for execution if you use the following options before your query:&lt;/P&gt;
&lt;PRE&gt;OPTIONS SASTRACE=',,,d' SASTRACELOC=SASLOG NOSTSUFFIX;&lt;/PRE&gt;
&lt;P&gt;The Oracle trunc() function won't change the data type. It simply aligns Oracle datetime values to the beginning of the day. I guess your SAS variable contains a SAS Date and not a SAS Datetime value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure why the SAS Oracle engine is doing this. Your best bet for having full control over the Oracle SQL is to use explicit pass-through SQL. And as you apparently got Oracle DBA support this person might then even help you to performance tweak this Oracle SQL.&lt;/P&gt;</description>
    <pubDate>Tue, 22 May 2018 23:57:06 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-05-22T23:57:06Z</dc:date>
    <item>
      <title>SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464226#M118345</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am just running&amp;nbsp;this simple&amp;nbsp;code but DBA were telling me&amp;nbsp;that&amp;nbsp;I am using truncate function but I am not using it. That's what DBA is seeing in Oracle Database WHERE&amp;nbsp; ( (TRUNC("PAID_DT") &amp;gt;=TO_DATE('01JAN2012','DDMONYYYY','NLS_DATE_LANGUAGE=American') ) AND&amp;nbsp; ( ( ( (TRUNC("SVC_BGN_DT") BETWEEN TO_DATE('01JAN2012','DDMONYYYY','NLS_DATE_LANGUAGE=American') AND TO_DATE('31DEC2017','DDMONYYYY','NLS_DATE_LANGUAGE=American') ) OR&amp;nbsp; (TRUNC("SVC_BGN_DT") BETWEEN TO_DATE('31DEC2017','DDMONYYYY','NLS_DATE_LANGUAGE=American') AND TO_DATE('01JAN2012','DDMONYYYY','NLS_DATE_LANGUAGE=American') ) ) ) )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should I do in the code&amp;nbsp;that oracle don't use the truncate function behind the scene. All the help will be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; work.Claims &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.TRNSCT_CNTL_NBR, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;t1.LINE_NBR,&lt;/P&gt;&lt;P&gt;t1.MEDICAID_ID,&lt;/P&gt;&lt;P&gt;t1.BILL_PRVDR_NPI&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; RADWPUB.Table &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.PAID_DT &lt;FONT face="Courier New" size="3"&gt;&amp;gt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'1Jan2012'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.SVC_BGN_DT &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;BETWEEN&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'1Jan2012'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;'31Dec2017'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.BILL_PRVDR_NPI = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'1013918960'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AND&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.CR_CD = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'0'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 22:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464226#M118345</guid>
      <dc:creator>Ahsan</dc:creator>
      <dc:date>2018-05-22T22:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464231#M118346</link>
      <description>Oracle stores dates as date times and you probably are using SAS dates, which only have the date part, so TRUNC is being used to convert the dates to the same type to allow for the comparisons.  If you used a DateTime instead would it help?&lt;BR /&gt;&lt;BR /&gt;where t1.paid_dt &amp;gt;= '01Jan2012:00:00:00'dt</description>
      <pubDate>Tue, 22 May 2018 22:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464231#M118346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-22T22:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464235#M118348</link>
      <description>I am running the query right now using your suggestion I will let you know shortly.</description>
      <pubDate>Tue, 22 May 2018 22:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464235#M118348</guid>
      <dc:creator>Ahsan</dc:creator>
      <dc:date>2018-05-22T22:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464237#M118349</link>
      <description>&lt;P&gt;Why do you want to avoid using trunc()?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it because indexes on the dates are not used?&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 23:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464237#M118349</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-22T23:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464238#M118350</link>
      <description>DBA still see the truncate function your suggestion didn't work&lt;BR /&gt;</description>
      <pubDate>Tue, 22 May 2018 23:25:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464238#M118350</guid>
      <dc:creator>Ahsan</dc:creator>
      <dc:date>2018-05-22T23:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464240#M118351</link>
      <description>it's taking a lot of time to run the query.</description>
      <pubDate>Tue, 22 May 2018 23:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464240#M118351</guid>
      <dc:creator>Ahsan</dc:creator>
      <dc:date>2018-05-22T23:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464243#M118352</link>
      <description>&lt;P&gt;1. Why is trunc() the reason for the long run time?&lt;/P&gt;
&lt;P&gt;2. Post the new native sql generated by by the SAS datetime&lt;/P&gt;
&lt;P&gt;3. You can use explicit pass through to run exactly the code you want, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
connect using RADWPUB;
CREATE TABLE work.Claims AS
select * from connection to RADWPUB (
 SELECT TRNSCT_CNTL_NBR,
 LINE_NBR,
 MEDICAID_ID,
 BILL_PRVDR_NPI 
 FROM Table
 WHERE PAID_DT &amp;gt;= to_date('1Jan2012')
 AND SVC_BGN_DT BETWEEN to_date('1Jan2012') AND 
 to_date('31Dec2017')
 AND BILL_PRVDR_NPI = '1013918960'
 AND CR_CD = '0'
);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 23:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464243#M118352</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-22T23:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464247#M118354</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165195"&gt;@Ahsan&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It's most likely not Oracle but the SAS Access to Oracle engine which adds this truncate to the code.&lt;/P&gt;
&lt;P&gt;You can see what SAS sends to Oracle for execution if you use the following options before your query:&lt;/P&gt;
&lt;PRE&gt;OPTIONS SASTRACE=',,,d' SASTRACELOC=SASLOG NOSTSUFFIX;&lt;/PRE&gt;
&lt;P&gt;The Oracle trunc() function won't change the data type. It simply aligns Oracle datetime values to the beginning of the day. I guess your SAS variable contains a SAS Date and not a SAS Datetime value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure why the SAS Oracle engine is doing this. Your best bet for having full control over the Oracle SQL is to use explicit pass-through SQL. And as you apparently got Oracle DBA support this person might then even help you to performance tweak this Oracle SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 23:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464247#M118354</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-22T23:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS not using Truncate function but Oracle showing Truncate funcation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464264#M118360</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&lt;SPAN&gt;Not sure why the SAS Oracle engine is doing this.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;As the SAS value is a date and the Oracle value is a datetime, some translation must be made as some point, and trunc() is a clean and easy way to do this.&lt;/P&gt;
&lt;P&gt;Now if this&amp;nbsp;prevents indexes from being used, it becomes a ruinous solution, and the SAS &lt;SPAN&gt;Oracle engine&amp;nbsp;&lt;/SPAN&gt;should definitely opt for another way to match the values. If that's the case I would classify the decision to use trunc() as a non-critical performance defect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 02:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-not-using-Truncate-function-but-Oracle-showing-Truncate/m-p/464264#M118360</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-23T02:42:05Z</dc:date>
    </item>
  </channel>
</rss>

