<?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: Sql Join condition using case statement: in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526263#M5067</link>
    <description>Would it be fair to remove the underscores and then do that comparison? This would solve one problem, but may cause others. I can show you how this is done, but I suspect it won't actually work for you because you need a different solution. &lt;BR /&gt;&lt;BR /&gt;Change your join to:&lt;BR /&gt;COMPRESS() will remove the underscores only in this. &lt;BR /&gt;&lt;BR /&gt;compress(a.colname, '_') = compress(b.colname, '_')</description>
    <pubDate>Fri, 11 Jan 2019 02:56:36 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-01-11T02:56:36Z</dc:date>
    <item>
      <title>Sql Join condition using case statement:</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526259#M5066</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;table1&lt;BR /&gt;ColName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;_1abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;_abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;table2&lt;BR /&gt;Colname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value&lt;BR /&gt;1abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $300&lt;BR /&gt;_abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $200&lt;BR /&gt;&lt;BR /&gt;When using sql left outer join, on a.colname=b.colname, the first record is not getting value (i.e _1abc from table1) because&lt;BR /&gt;of the underscore. (Here a case statement would help or some regex in sql)&lt;BR /&gt;So how to bring values from table2 as below:&lt;BR /&gt;&lt;BR /&gt;so the output should be&lt;BR /&gt;&lt;BR /&gt;result:&lt;BR /&gt;ColName&amp;nbsp;&amp;nbsp; Value&amp;nbsp; &amp;nbsp;&lt;BR /&gt;_1abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;_abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $200&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 02:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526259#M5066</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-01-11T02:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sql Join condition using case statement:</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526263#M5067</link>
      <description>Would it be fair to remove the underscores and then do that comparison? This would solve one problem, but may cause others. I can show you how this is done, but I suspect it won't actually work for you because you need a different solution. &lt;BR /&gt;&lt;BR /&gt;Change your join to:&lt;BR /&gt;COMPRESS() will remove the underscores only in this. &lt;BR /&gt;&lt;BR /&gt;compress(a.colname, '_') = compress(b.colname, '_')</description>
      <pubDate>Fri, 11 Jan 2019 02:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526263#M5067</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-11T02:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sql Join condition using case statement:</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526264#M5068</link>
      <description>&lt;P&gt;Compressing underscore will compress underscore in any position. Ideally if the first position is underscore and second position is number, ignore firstposition underscore and compare from second psoition, like _1abc and 1abc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 03:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526264#M5068</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-01-11T03:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sql Join condition using case statement:</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526280#M5069</link>
      <description>&lt;P&gt;If doing the join on fields stripped of any leading underscore is OK:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
c = "_1abc"; output;
c = "_abc"; output;
run;

data t2;
c = "1abc"; a = 1; output;
c = "_abc"; a = 2; output;
run;

proc sql;
select t1.c, t2.a
from t1 inner join 
    t2 on prxchange("s/^_//o", 1, t1.c) = prxchange("s/^_//o", 1, t2.c);
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                 c             a
                                  ---------------
                                  _1abc         1
                                  _abc          2
&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 04:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Sql-Join-condition-using-case-statement/m-p/526280#M5069</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-01-11T04:23:36Z</dc:date>
    </item>
  </channel>
</rss>

