<?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: Data type mismatch causing issue with PROC SQL in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751726#M1231</link>
    <description>&lt;P&gt;Fantastic!&amp;nbsp; Thanks so much for your help (and patience)!&amp;nbsp; I am new to this.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jul 2021 13:14:06 GMT</pubDate>
    <dc:creator>TS_Hum</dc:creator>
    <dc:date>2021-07-02T13:14:06Z</dc:date>
    <item>
      <title>Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751576#M1220</link>
      <description>&lt;P&gt;Why are Res1 and Res2 always zero?&amp;nbsp; I reduced my problem to the code below.&amp;nbsp; I assume the issue is being caused by a mismatch of the data types, but I am not understanding how to address it.&amp;nbsp; Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*SETUP*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table MyListTable (&lt;BR /&gt;MyVal varchar(100)&lt;BR /&gt;);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;insert into MyListTable&lt;BR /&gt;set MyVal='AR'&lt;BR /&gt;set MyVal='ES';&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;/*THE PROBLEM*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table test as&lt;BR /&gt;select b.memname, a.MyVal&lt;BR /&gt;, index(a.MyVal, 'AR') as A_Found&lt;BR /&gt;, index(b.memname, 'AR') as B_Found&lt;BR /&gt;, index(upcase(b.memname), upcase(a.myval)) as Res1&lt;BR /&gt;, case when upcase(b.memname) like ('%' || a.MyVal || '%') then 1 else 0 end as Res2&lt;BR /&gt;from MyListTable a, DICTIONARY.TABLES b&lt;BR /&gt;where b.libname='SASHELP'&lt;BR /&gt;and b.memname like '%AR%';&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 21:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751576#M1220</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-07-01T21:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751579#M1221</link>
      <description>&lt;P&gt;When you get an error message, then 100% of the time you need to show us the LOG for this PROC, the entire log for this PROC, all of it, every single character of the log for this PROC, do not select and choose parts of the log for this PROC. That way we can see the code, the ERROR message(s), the WARNING message(s) and the NOTE message(s). Copy the LOG as text and paste it into the box that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 21:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751579#M1221</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-01T21:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751646#M1225</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381792"&gt;@TS_Hum&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your examples variable &lt;FONT face="courier new,courier"&gt;MyVal&lt;/FONT&gt; contains 98 &lt;EM&gt;trailing blanks&lt;/EM&gt;. You need to remove them, e.g., with the TRIM function when using &lt;FONT face="courier new,courier"&gt;MyVal&lt;/FONT&gt; in the INDEX function or in concatenations with the || operator. So, just replace &lt;FONT face="courier new,courier"&gt;a.myval&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;trim(a.myval)&lt;/FONT&gt; in both places.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 08:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751646#M1225</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T08:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751708#M1228</link>
      <description>&lt;P&gt;My apologies... I will try to remember to include that in future posts.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751708#M1228</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-07-02T12:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751710#M1229</link>
      <description>&lt;P&gt;Thanks so much!&amp;nbsp; I have an SQL background and am still getting used to SAS nuances.&amp;nbsp; When I initially got the results and it didn't match what I expected, I started going down this path thinking the spaces were being counted, but I stopped short of using a trim function after I used the LENGTH function and found that it was showing me the correct length of each value.&amp;nbsp; Obviously, it didn't count everything.&amp;nbsp; Is there another function that shows the length of everything, spaces included?&amp;nbsp; In SQL, there is LEN (similar to length here), but then there is also DATALENGTH(), which shows everything.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751710#M1229</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-07-02T12:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751718#M1230</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381792"&gt;@TS_Hum&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there another function that shows the length of everything, spaces included?&amp;nbsp; In SQL, there is LEN (similar to length here), but then there is also DATALENGTH(), which shows everything.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, there is: the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1kkgqelwql5syn1mr4zx8ia0nup.htm" target="_blank" rel="noopener"&gt;LENGTHC function&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751718#M1230</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T12:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data type mismatch causing issue with PROC SQL</title>
      <link>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751726#M1231</link>
      <description>&lt;P&gt;Fantastic!&amp;nbsp; Thanks so much for your help (and patience)!&amp;nbsp; I am new to this.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 13:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Data-type-mismatch-causing-issue-with-PROC-SQL/m-p/751726#M1231</guid>
      <dc:creator>TS_Hum</dc:creator>
      <dc:date>2021-07-02T13:14:06Z</dc:date>
    </item>
  </channel>
</rss>

