<?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: numeric works, non-numeric fails in my where statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440891#M28452</link>
    <description>&lt;P&gt;Thank you so much - this worked like a dream!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 14:11:00 GMT</pubDate>
    <dc:creator>stogez13</dc:creator>
    <dc:date>2018-02-28T14:11:00Z</dc:date>
    <item>
      <title>numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440837#M28441</link>
      <description>Hi, When I run this piece of code (query a numeric variable) it works proc sql noprint; select Centre, Branch, Product, Contract into :Centre, :Branch, :Product, :Contract from DD1; %put &amp;amp;Centre &amp;amp;Branch &amp;amp;Product &amp;amp;Contract; PROC SQL; connect to odbc (DSN=GBGB user=&amp;amp;DB2uid password=&amp;amp;DB2pwd); CREATE TABLE DD2 AS SELECT * FROM CONNECTION TO odbc ( SELECT FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6, FIELD1 AS Key FROM EXAMPLETABLE where FIELD1=&amp;amp;Centre AND FIELD2=&amp;amp;Branch AND FIELD3=&amp;amp;Product AND FIELD4=&amp;amp;Contract for fetch only with ur; ); This returns the data I was expecting - but when I run a similar piece of code it fails and I think it's because the variable I'm querying in the WHERE statement is non-numeric. Do I need to do something different? proc sql noprint; select CheckUp1, CheckUp2 into :CheckUp1, :CheckUp2 from DD2; %put &amp;amp;CheckUp1 &amp;amp;CheckUp2; PROC SQL; connect to odbc (DSN=GBGB user=&amp;amp;DB2uid password=&amp;amp;DB2pwd); CREATE TABLE DD3 AS SELECT * FROM CONNECTION TO odbc ( SELECT FIELD6, FIELD7, FIELD8, FIELD9, FIELD6 AS Key FROM EXAMPLETABLE2 where FIELD6=&amp;amp;CheckUp1 AND FIELD7=&amp;amp;CheckUp2 for fetch only with ur; ); Any help much appreciated - thanks</description>
      <pubDate>Wed, 28 Feb 2018 11:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440837#M28441</guid>
      <dc:creator>stogez13</dc:creator>
      <dc:date>2018-02-28T11:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440842#M28442</link>
      <description>&lt;P&gt;[Big Wall of Text] - Sorry, can't make head not tail of it.&amp;nbsp; Please reformat your post, use returns, paragraphs and such like so text is readable.&amp;nbsp; For code, use the code blocks - it is the {i} above the post area - this will highlight code and retain source formatting so that it is readable.&lt;/P&gt;
&lt;P&gt;I suspect on your second query, you would need to put the macro variables in quotes otherwise they appear as numbers:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where FIELD6="&amp;amp;CheckUp1." AND FIELD7="&amp;amp;CheckUp2."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 11:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440842#M28442</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-28T11:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440847#M28443</link>
      <description>&lt;P&gt;Sorry - first post &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will try to reformat code to make it understandable - thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 11:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440847#M28443</guid>
      <dc:creator>stogez13</dc:creator>
      <dc:date>2018-02-28T11:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440852#M28444</link>
      <description>&lt;PRE&gt;proc sql noprint; 
select Centre, Branch, Product, Contract 
into :Centre, :Branch, :Product, :Contract 
from DD1; 
%put &amp;amp;Centre &amp;amp;Branch &amp;amp;Product &amp;amp;Contract; 

PROC SQL; 
connect to odbc (DSN=GBGB user=&amp;amp;DB2uid password=&amp;amp;DB2pwd); CREATE TABLE DD2 AS SELECT * FROM CONNECTION TO odbc 
( 
SELECT FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6, 
FIELD1 AS Key 
FROM EXAMPLETABLE 
where FIELD1=&amp;amp;Centre AND 
FIELD2=&amp;amp;Branch AND 
FIELD3=&amp;amp;Product AND
 FIELD4=&amp;amp;Contract 
for fetch only with ur; 
); 

This returns the data I was expecting - but when I run a similar piece of code it fails and I think it's because the variable I'm querying in the WHERE statement is non-numeric. Do I need to do something different? 

proc sql noprint; 
select CheckUp1, CheckUp2 
into :CheckUp1, :CheckUp2 from DD2; 
%put &amp;amp;CheckUp1 &amp;amp;CheckUp2; 
PROC SQL; 
connect to odbc (DSN=GBGB user=&amp;amp;DB2uid password=&amp;amp;DB2pwd); CREATE TABLE DD3 AS SELECT * FROM CONNECTION TO odbc 
( 
SELECT FIELD6, FIELD7, FIELD8, FIELD9, 
FIELD6 AS Key 
FROM EXAMPLETABLE2 
where 
FIELD6=&amp;amp;CheckUp1 AND 
FIELD7=&amp;amp;CheckUp2 
for fetch only with ur; 
);&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 11:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440852#M28444</guid>
      <dc:creator>stogez13</dc:creator>
      <dc:date>2018-02-28T11:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440853#M28445</link>
      <description>&lt;P&gt;With character variables, use quotes as suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 11:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440853#M28445</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-28T11:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440854#M28446</link>
      <description>&lt;P&gt;The second bit returns the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI describe error: [DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for OS/390 and z/OS]EH3920197742 NOT COLUMN OF INSERTED/UPDATED TABLE, OR ANY TABLE IN A FROM CLAUSE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I put FIELD6="&amp;amp;CheckUp1" AND FIELD7="&amp;amp;CheckUp2" it doesn't return anything&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I put FIELD6='EH3920197742' then it works - so I know the data is there, it just can't find it when I use the variable name&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 11:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440854#M28446</guid>
      <dc:creator>stogez13</dc:creator>
      <dc:date>2018-02-28T11:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440866#M28448</link>
      <description>&lt;P&gt;And what does &amp;amp;Checkup1 and 2 look like?&amp;nbsp; Look in your log, turn macro printing functions on with:&lt;/P&gt;
&lt;P&gt;options mlogic mprint symbolgen;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does &amp;amp;Checkup1 =&amp;nbsp;&lt;SPAN&gt;EH3920197742?&amp;nbsp; I would guess it doesn't.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 12:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440866#M28448</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-28T12:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440868#M28449</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/196135"&gt;@stogez13&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The second bit returns the following error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: CLI describe error: [DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for OS/390 and z/OS]EH3920197742 NOT COLUMN OF INSERTED/UPDATED TABLE, OR ANY TABLE IN A FROM CLAUSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I put FIELD6="&amp;amp;CheckUp1" AND FIELD7="&amp;amp;CheckUp2" it doesn't return anything&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if I put FIELD6='EH3920197742' then it works - so I know the data is there, it just can't find it when I use the variable name&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This might be because ANSI SQL doesn't like double quotes for string literals. Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FIELD6=%qsysfunc(dequote("'&amp;amp;CheckUp1'")) AND FIELD7=%qsysfunc(dequote("'&amp;amp;CheckUp2'"))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 13:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440868#M28449</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-28T13:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440877#M28450</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;This might be because ANSI SQL doesn't like double quotes for string literals. Try&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;FIELD6&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;%qsysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;dequote&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"'&amp;amp;CheckUp1'"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; AND FIELD7&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;%qsysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;dequote&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"'&amp;amp;CheckUp2'"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="UserSignature lia-message-signature"&gt;You don't want or need macro quoting here. The values are already in regular quotes!.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="UserSignature lia-message-signature"&gt;So just use normal %SYSFUNC() instead of %QSYSFUNC().&lt;/DIV&gt;
&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Feb 2018 13:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440877#M28450</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-28T13:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440880#M28451</link>
      <description>&lt;P&gt;Have to say, I just copied it from a solution that google found for me &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 13:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440880#M28451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-28T13:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: numeric works, non-numeric fails in my where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440891#M28452</link>
      <description>&lt;P&gt;Thank you so much - this worked like a dream!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 14:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/numeric-works-non-numeric-fails-in-my-where-statement/m-p/440891#M28452</guid>
      <dc:creator>stogez13</dc:creator>
      <dc:date>2018-02-28T14:11:00Z</dc:date>
    </item>
  </channel>
</rss>

