<?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: Issue with using TRUNC in my SQL query within PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537471#M147827</link>
    <description>&lt;P&gt;They're functions with the same name, but I don't believe they do the same functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TRUNC() in SQL appears to round the date to a specific format/interval, whereas TRUNC in SAS truncates a number (no rounding).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain what TRUNC with Q and DDD should return?&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263293"&gt;@Jiunn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There is a TRUNC function in SAS and I believe the issue is it is recognizing the SQL TRUNC as the SAS TRUNC ... SAS TRUNC requires the 2nd argument to be numeric but Oracle SQL TRUNC allows different arguments like 'Q', 'DDD', ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure how I should use INTX in this context - replace the JOIN?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Feb 2019 17:23:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-02-21T17:23:53Z</dc:date>
    <item>
      <title>Issue with using TRUNC in my SQL query within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537458#M147820</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this query in the SQL environment, it worked ... but when I embed this into proc sql, I keep getting the error message "Function TRUNC requires a numeric expression as argument 2."&amp;nbsp; Is there a workaround for this?&amp;nbsp; Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table tst as&lt;BR /&gt;SELECT common_id,&lt;BR /&gt;item_type,&lt;BR /&gt;item_amt,&lt;BR /&gt;CASE&lt;BR /&gt;WHEN a.item_term &amp;lt; '2'&lt;BR /&gt;AND a.item_term &amp;lt;&amp;gt; ' ' THEN a.item_term&lt;BR /&gt;WHEN bill.cu_bill_term IS NOT NULL THEN t_bill.strm&lt;BR /&gt;WHEN t_due.strm IS NOT NULL THEN t_due.strm&lt;BR /&gt;ELSE t_eff.strm&lt;BR /&gt;END AS item_term&lt;BR /&gt;FROM hcs.ps_item_sf a&lt;BR /&gt;left join hcs.ps_cu_bill_line bill&lt;BR /&gt;ON bill.emplid = a.common_id&lt;BR /&gt;AND bill.cu_bill_term = a.item_term&lt;BR /&gt;left join hcs.ps_term_tbl t_bill&lt;BR /&gt;ON t_bill.acad_career = 'GRAD'&lt;BR /&gt;AND Trunc(bill.start_dt, 'Q') = Trunc(t_bill.term_begin_dt, 'Q')&lt;BR /&gt;left join hcs.ps_term_tbl t_due&lt;BR /&gt;ON t_due.acad_career = 'GRAD'&lt;BR /&gt;AND Trunc(a.due_dt, 'Q') = Trunc(t_due.term_begin_dt, 'Q')&lt;BR /&gt;left join hcs.ps_term_tbl t_eff&lt;BR /&gt;ON t_eff.acad_career = 'GRAD'&lt;BR /&gt;AND Trunc(a.item_effective_dt, 'Q') = Trunc(t_eff.term_begin_dt, 'Q')&lt;BR /&gt;;&lt;BR /&gt;quit; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 16:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537458#M147820</guid>
      <dc:creator>Jiunn</dc:creator>
      <dc:date>2019-02-21T16:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using TRUNC in my SQL query within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537460#M147822</link>
      <description>TRUNC isn't a SAS function, you need to find the analogous SAS function, which I think is INTNX().</description>
      <pubDate>Thu, 21 Feb 2019 16:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537460#M147822</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-21T16:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using TRUNC in my SQL query within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537465#M147824</link>
      <description>&lt;P&gt;There is a TRUNC function in SAS and I believe the issue is it is recognizing the SQL TRUNC as the SAS TRUNC ... SAS TRUNC requires the 2nd argument to be numeric but Oracle SQL TRUNC allows different arguments like 'Q', 'DDD', ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure how I should use INTX in this context - replace the JOIN?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 17:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537465#M147824</guid>
      <dc:creator>Jiunn</dc:creator>
      <dc:date>2019-02-21T17:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using TRUNC in my SQL query within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537471#M147827</link>
      <description>&lt;P&gt;They're functions with the same name, but I don't believe they do the same functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TRUNC() in SQL appears to round the date to a specific format/interval, whereas TRUNC in SAS truncates a number (no rounding).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain what TRUNC with Q and DDD should return?&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263293"&gt;@Jiunn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There is a TRUNC function in SAS and I believe the issue is it is recognizing the SQL TRUNC as the SAS TRUNC ... SAS TRUNC requires the 2nd argument to be numeric but Oracle SQL TRUNC allows different arguments like 'Q', 'DDD', ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure how I should use INTX in this context - replace the JOIN?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 17:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537471#M147827</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-21T17:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using TRUNC in my SQL query within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537476#M147828</link>
      <description>&lt;P&gt;There is no SQL function named TRUNC().&amp;nbsp; There is one that Oracle has created that you can use in SQL code to run in an Oracle database.&amp;nbsp; Try using INTNX() function instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('dtqtr',t_eff.term_begin_dt,0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;1677  data test;
1678   now=datetime();
1679   want=intnx('dtqtr',now,0) ;
1680   format _all_ datetime19.;
1681   put (_all_) (=);
1682  run;

now=21FEB2019:12:40:35 want=01JAN2019:00:00:00
&lt;/PRE&gt;
&lt;P&gt;Or just use PUT() with appropriate format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(a.item_effective_dt,dtyyqc6.) = put(t_eff.term_begin_dt, dtyyqc6.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 17:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-with-using-TRUNC-in-my-SQL-query-within-PROC-SQL/m-p/537476#M147828</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-21T17:47:00Z</dc:date>
    </item>
  </channel>
</rss>

