<?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: Full outer join - issue with listing the linked variable using Coalesce in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284027#M311491</link>
    <description>&lt;P&gt;Thanks for the explanation Chris, it is working now!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2016 13:37:18 GMT</pubDate>
    <dc:creator>brulard</dc:creator>
    <dc:date>2016-07-13T13:37:18Z</dc:date>
    <item>
      <title>Full outer join - issue with listing the linked variable using Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284017#M311489</link>
      <description>&lt;P&gt;hi -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to join two tables without losing any of the key variables from both tables. I'm looking to achieve this using proc sql full outer join.&lt;/P&gt;&lt;P&gt;The problem I am trying to solve is that I want the common variable to both tables, to appear as one column. I heard that the 'coalesce' function, can achieve this, however when I tried, the observations from the variable is listed as a binary (either 0 or 1).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Base SAS code that achieves result I am looking to get, :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want; 
   merge A B; 
      by ID;
        run;&lt;/PRE&gt;&lt;P&gt;SQL code I used along with the coalesce function, which gives me binary result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;  create table Want as
  select coalesce(a.ID=b.ID) as ID, a.expi, b.sta_dt, b.ts_acn_sts_cd, b.ts_acn_sts_rsn_cd
         from A as a full outer join B as b  on
             a.ID=b.ID; 
                 quit;&lt;/PRE&gt;&lt;P&gt;To note: There are no blank variables in either table A or B, and my ID column (from both tables) is formatted as 11 text characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I look forward to receiving your suggestion, thanks&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 12:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284017#M311489</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-07-13T12:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Full outer join - issue with listing the linked variable using Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284019#M311490</link>
      <description>Hi&lt;BR /&gt;Try changing the coalesce function to:&lt;BR /&gt;coalesce(a.id, b.id)&lt;BR /&gt;The way it works is to use the first non-missing value in the variables listed.&lt;BR /&gt;How you have coded it will compare the values of the two variables, hence the binary result.&lt;BR /&gt;Hope this helps.&lt;BR /&gt;Cheers&lt;BR /&gt;Chris</description>
      <pubDate>Wed, 13 Jul 2016 13:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284019#M311490</guid>
      <dc:creator>rivieralad</dc:creator>
      <dc:date>2016-07-13T13:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Full outer join - issue with listing the linked variable using Coalesce</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284027#M311491</link>
      <description>&lt;P&gt;Thanks for the explanation Chris, it is working now!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 13:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-outer-join-issue-with-listing-the-linked-variable-using/m-p/284027#M311491</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2016-07-13T13:37:18Z</dc:date>
    </item>
  </channel>
</rss>

