<?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: Joining Fields with different lengths using PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356974#M274185</link>
    <description>&lt;P&gt;WHERE requires that you compare the same type (character to character, or numeric to numeric). &amp;nbsp;That's because SAS uses the WHERE clause for filtering. &amp;nbsp;It can't perform extensive data manipulation, such as type conversions. &amp;nbsp;So CAST creates a character string and you can't compare that to a numeric. &amp;nbsp;(I suppose you could CAST bot of them, and compare the first 7 digits of each ... or you could try my original suggestion.)&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2017 18:50:28 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-08T18:50:28Z</dc:date>
    <item>
      <title>Joining Fields with different lengths using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356964#M274182</link>
      <description>&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;I'm attempting to join two numeric fields (they are both IDs)&amp;nbsp;with two different lengths from two different tables: Field1 has a length of 7 and Field2 has&amp;nbsp;a length of 9, however the first 7 numerical values from field2 equals field1.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;Example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;TableA.Field1 = 1234567&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;TableB.Field2 = 123456789&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;I attempted the following using PROC SQL&amp;nbsp;and did not have much success.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;TableA as t1 INNER JOIN TableB as t2 on t1.Field1 = SUBSTR(CAST(t2.Field2 as CHAR(10)),1,7)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;Any help would be greatly appreciated =).&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 18:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356964#M274182</guid>
      <dc:creator>PhatRam33</dc:creator>
      <dc:date>2017-05-08T18:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Fields with different lengths using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356970#M274183</link>
      <description>&lt;P&gt;You don't say how you measure the lack of success, but ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps the CAST operation is right-hand justifying within the length of 10. &amp;nbsp;That would cause a mismatch. &amp;nbsp;If this would work, it eliminates the need for conversion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where t1.field1 = int(t2.field2/100)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it would only work if you always compare 7 digits to 9 digits not (for example) 7 digits to 8 digits.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 18:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356970#M274183</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-08T18:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Fields with different lengths using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356973#M274184</link>
      <description>&lt;P&gt;Lack of Success = 0 lol. I tried a few variations of the join provided and received and error each time primarily related to a data type issue.&amp;nbsp; Yes, it is always compare 7 to 9 digits. Why would this be in the where clause, just curious?&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 18:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356973#M274184</guid>
      <dc:creator>PhatRam33</dc:creator>
      <dc:date>2017-05-08T18:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Fields with different lengths using PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356974#M274185</link>
      <description>&lt;P&gt;WHERE requires that you compare the same type (character to character, or numeric to numeric). &amp;nbsp;That's because SAS uses the WHERE clause for filtering. &amp;nbsp;It can't perform extensive data manipulation, such as type conversions. &amp;nbsp;So CAST creates a character string and you can't compare that to a numeric. &amp;nbsp;(I suppose you could CAST bot of them, and compare the first 7 digits of each ... or you could try my original suggestion.)&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 18:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-Fields-with-different-lengths-using-PROC-SQL/m-p/356974#M274185</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-08T18:50:28Z</dc:date>
    </item>
  </channel>
</rss>

