<?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_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742111#M29174</link>
    <description>&lt;P&gt;Why dou use the DATEPART function on something that seems to be a date already?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also do not need the GROUP BY when your WHERE condition already restricts the observations to one group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you may have a problem converting the UUID string to the correct type in the DBMS.&lt;/P&gt;</description>
    <pubDate>Tue, 18 May 2021 11:52:26 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-05-18T11:52:26Z</dc:date>
    <item>
      <title>SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741819#M29154</link>
      <description>&lt;P&gt;SYMBOLGEN: Macro variable T_CLIENT_ID resolves to 00000031-B081-4E97-9437-F20CF874F857&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select&lt;BR /&gt;COALESCE(sum(abc.step_sum),0)&lt;BR /&gt;into :SumLoans_12m&lt;BR /&gt;from&lt;BR /&gt;RTDM_ABT.ABT_CONTRACT abc&lt;BR /&gt;where abc.CLIENT_ID = "&amp;amp;T_CLIENT_ID"&lt;BR /&gt;and today() -&amp;nbsp;datepart(abc.CONTRACT_BEGINDATE)&amp;nbsp; &amp;lt;= 365&lt;BR /&gt;and abc.DML_FLAG NE 1&lt;BR /&gt;group by abc.CLIENT_ID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Format CONTRACT_BEGINDATE&amp;nbsp; = 2021-01-14 00:00:00.000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error. 152499 1621241630 no_name 0 SQL (437&lt;BR /&gt;ACCESS ENGINE: SQL statement was not passed to the DBMS, SAS will do the processing. 152500 1621241630 no_name 0 SQL (437&lt;BR /&gt;152501 1621241630 no_name 0 SQL (437&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its work fo t-sql:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select&amp;nbsp;coalesce(sum(step_sum),0)&lt;BR /&gt;from&lt;BR /&gt;RTDM_ABT.ABT_CONTRACT abc&lt;BR /&gt;where abc.client_id = '00000AAB-F0E1-4CFA-9D91-C598FCDFAB4F'&lt;BR /&gt;and GETDATE() - abc.CONTRACT_BEGINDATE &amp;lt;= 365&lt;BR /&gt;and abc.DML_FLAG &amp;lt;&amp;gt; 1&lt;BR /&gt;group by abc.client_id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where's my mistake? Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 09:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741819#M29154</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-17T09:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741825#M29155</link>
      <description>&lt;P&gt;Based on the error message I'm assuming you are doing SQL Pass-Thru to a DBMS i.e. the SQL code is run inside the DBMS and not run by SAS.&amp;nbsp;&lt;BR /&gt;The error message is telling you that the SQL contains some SAS syntax that the DBMS does not understand, so the query is passed back to SAS and SAS runs the query.&amp;nbsp;&lt;BR /&gt;My educated guess is the following function calls are probably the issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;and &lt;FONT color="#FF0000"&gt;today&lt;/FONT&gt;() -&amp;nbsp;&lt;FONT color="#FF0000"&gt;datepart&lt;/FONT&gt;(abc.CONTRACT_BEGINDATE)&amp;nbsp; &amp;lt;= 365&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd start by removing or changing those to a hardcoded value and see if the query works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 10:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741825#M29155</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-17T10:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741831#M29156</link>
      <description>&lt;P&gt;I also had such an assumption and it was confirmed, after deleting this line, the code works, but how to make this script work with this line is not yet clear to me.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 11:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741831#M29156</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-17T11:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741917#M29162</link>
      <description>&lt;P&gt;So now we know that's the problem, the question is how to correct the code.&lt;/P&gt;
&lt;P&gt;The first thing we need to know is the format of&amp;nbsp;&lt;SPAN&gt;abc.CONTRACT_BEGINDATE, as you're using the datepart() function I would assume it's a SAS date/time value. If it is a SAS data/time value then I think the following would work (untested):&lt;BR /&gt;&lt;BR /&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 _null_ ;
	now=datetime() ;
	diff=365*24*60*60 ;
	put now= datetime. now= ; 
	call symput("mvNow",put(now,14.2)) ;
run ;

%put mvNow= &amp;amp;mvNow ;
proc sql;
select
COALESCE(sum(abc.step_sum),0)
into :SumLoans_12m
from
RTDM_ABT.ABT_CONTRACT abc
where abc.CLIENT_ID = "&amp;amp;T_CLIENT_ID"
and &amp;amp;mvNow - abc.CONTRACT_BEGINDATE  &amp;lt;= (365*24*60*60)
and abc.DML_FLAG NE 1
group by abc.CLIENT_ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not certain this will work, as I do not use SQL pass-thru, and I'm not sure if the SAS Macro Variable will be resolved, prior to the code being passed to DBMS (I believe it does).&amp;nbsp;&lt;BR /&gt;You might also want to change the (365*24*60*60) to 31536000 (number of seconds in 365 days)&lt;BR /&gt;Again this assumes&amp;nbsp;&lt;SPAN&gt;abc.CONTRACT_BEGINDATE is a SAS date/time value (number of seconds since 00:00:00 01Jan1960)&lt;/SPAN&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 16:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/741917#M29162</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-17T16:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742068#M29167</link>
      <description>Errors:&lt;BR /&gt;&lt;BR /&gt;SAS_SQL: Failed to get a DBMS-specific datetime value. 163681 1621320885 no_name 0 SQL (469&lt;BR /&gt;SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error. 163682</description>
      <pubDate>Tue, 18 May 2021 07:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742068#M29167</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-18T07:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742069#M29168</link>
      <description>&lt;P&gt;&lt;SPAN&gt;CONTRACT_BEGINDATE&amp;nbsp; ( 2021-01-14 00:00:00.000 )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 07:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742069#M29168</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-18T07:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742070#M29169</link>
      <description>Full log:&lt;BR /&gt;The SAS System&lt;BR /&gt;&lt;BR /&gt;memory 265.37k&lt;BR /&gt;OS Memory 29476.00k&lt;BR /&gt;Timestamp 18.05.2021 09:54:45&lt;BR /&gt;Page Faults 0&lt;BR /&gt;Page Reclaims 136&lt;BR /&gt;Page Swaps 0&lt;BR /&gt;Voluntary Context Switches 0&lt;BR /&gt;Involuntary Context Switches 1&lt;BR /&gt;Block Input Operations 0&lt;BR /&gt;Block Output Operations 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MLOGIC(MEQUIBEHSCOREUPRE): %PUT mvNow= &amp;amp;mvNow&lt;BR /&gt;SYMBOLGEN: Macro variable MVNOW resolves to 1936950885.51&lt;BR /&gt;mvNow= 1936950885.51&lt;BR /&gt;MPRINT(MEQUIBEHSCOREUPRE): proc sql;&lt;BR /&gt;SYMBOLGEN: Macro variable T_CLIENT_ID resolves to 00000031-B081-4E97-9437-F20CF874F857&lt;BR /&gt;SYMBOLGEN: Macro variable MVNOW resolves to 1936950885.51&lt;BR /&gt;MPRINT(MEQUIBEHSCOREUPRE): select COALESCE(sum(abc.step_sum),0) into :SumLoans_12m from RTDM_ABT.ABT_CONTRACT abc where abc.CLIENT_ID = "00000031-B081-4E97-9437-F20CF874F857" and 1936950885.51&lt;BR /&gt;- abc.CONTRACT_BEGINDATE &amp;lt;= (365*24*60*60) and abc.DML_FLAG NE 1 group by abc.CLIENT_ID;&lt;BR /&gt;163677 1621320885 no_name 0 SQL (469&lt;BR /&gt;SQLSRV_37146: Prepared: on connection 0 163678 1621320885 no_name 0 SQL (469&lt;BR /&gt;SELECT * FROM rtdm_abt . ABT_CONTRACT 163679 1621320885 no_name 0 SQL (469&lt;BR /&gt;163680 1621320885 no_name 0 SQL (469&lt;BR /&gt;SAS_SQL: Failed to get a DBMS-specific datetime value. 163681 1621320885 no_name 0 SQL (469&lt;BR /&gt;SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error. 163682 1621320885 no_name 0 SQL (469&lt;BR /&gt;ACCESS ENGINE: SQL statement was not passed to the DBMS, SAS will do the processing. 163683 1621320885 no_name 0 SQL (469&lt;BR /&gt;163684 1621320885 no_name 0 SQL (469&lt;BR /&gt;SQLSRV_37147: Prepared: on connection 0 163685 1621320885 no_name 0 SQL (469&lt;BR /&gt;SELECT STEP_SUM , CLIENT_ID , CONTRACT_BEGINDATE , DML_FLAG FROM rtdm_abt . ABT_CONTRACT WHERE ( ( CLIENT_ID = '00000031-B081-4E97-9437-F20CF874F857' ) AND ( DML_FLAG &amp;lt;&amp;gt; 1 ) )&lt;BR /&gt;163686 1621320885 no_name 0 SQL (469&lt;BR /&gt;163687 1621320885 no_name 0 SQL (469&lt;BR /&gt;163688 1621320885 no_name 0 SQL (469&lt;BR /&gt;SQLSRV_37148: Executed: on connection 0 163689 1621320885 no_name 0 SQL (469&lt;BR /&gt;Prepared statement SQLSRV_37147 163690 1621320885 no_name 0 SQL (469&lt;BR /&gt;163691 1621320885 no_name 0 SQL (469&lt;BR /&gt;NOTE: No rows were selected.&lt;BR /&gt;MPRINT(MEQUIBEHSCOREUPRE): quit;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 May 2021 07:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742070#M29169</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-18T07:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742093#M29172</link>
      <description>I understand it is necessary to convert CONTRACT_BEGINDATE (2021-01-14 00:00: 00.000) to format SAS, I think it would help</description>
      <pubDate>Tue, 18 May 2021 09:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742093#M29172</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-18T09:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742111#M29174</link>
      <description>&lt;P&gt;Why dou use the DATEPART function on something that seems to be a date already?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also do not need the GROUP BY when your WHERE condition already restricts the observations to one group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you may have a problem converting the UUID string to the correct type in the DBMS.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 11:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742111#M29174</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-18T11:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742119#M29175</link>
      <description>Yes, Hooked from the test script, thanks for the remark. But this does not solve the mistake.&lt;BR /&gt;And it doesn't work for me with and without datepart()</description>
      <pubDate>Tue, 18 May 2021 12:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742119#M29175</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-18T12:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS_SQL: Unable to convert the query to a DBMS specific SQL statement due to an error.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742622#M29200</link>
      <description>proc sql noprint;&lt;BR /&gt;select&lt;BR /&gt;sum(step_sum)&lt;BR /&gt;into :SumLoans_12m&lt;BR /&gt;from&lt;BR /&gt;RTDM_ABT.ABT_CONTRACT abc&lt;BR /&gt;where abc.client_id = "&amp;amp;T_CLIENT_ID"&lt;BR /&gt;and abc.DML_FLAG &amp;lt;&amp;gt; 1&lt;BR /&gt;and datepart(abc.CONTRACT_BEGINDATE) between today() - 365 and today();&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It worked for me, in double it's nice that I came up with it myself ))</description>
      <pubDate>Thu, 20 May 2021 10:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-SQL-Unable-to-convert-the-query-to-a-DBMS-specific-SQL/m-p/742622#M29200</guid>
      <dc:creator>DimaSup</dc:creator>
      <dc:date>2021-05-20T10:11:53Z</dc:date>
    </item>
  </channel>
</rss>

