<?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 Merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975859#M378200</link>
    <description>&lt;P&gt;What is the relationship between those datasets?&lt;/P&gt;
&lt;P&gt;One-to-one (as shown in your example)?&lt;/P&gt;
&lt;P&gt;One-to-many/many-to-one?&lt;/P&gt;
&lt;P&gt;Many-to-many?&lt;/P&gt;</description>
    <pubDate>Sat, 27 Sep 2025 13:02:20 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2025-09-27T13:02:20Z</dc:date>
    <item>
      <title>Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975854#M378196</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to perform full merge of two data sets.&lt;/P&gt;
&lt;P&gt;I want to define the rule-&lt;/P&gt;
&lt;P&gt;If customer&amp;nbsp; exist in one table then take Y information from this table.&lt;/P&gt;
&lt;P&gt;IF customer exit in both tables then do as following-&lt;/P&gt;
&lt;P&gt;IF Y value is not null in both tables then take it from table aa&lt;/P&gt;
&lt;P&gt;IF Y value is&amp;nbsp; null in one&amp;nbsp; table&amp;nbsp; then take Y value from the table where it is not null&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the way to do it via data step?&lt;/P&gt;
&lt;P&gt;what is the way to do it via proc sql?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aa;
input CustID y;
cards;
111 .
222 20
444 50
555 70
123 35
;
run;
data bb;
input CustID y;
cards;
111 15
222 20
333 35
444 .
666 80
123 27
;
run;
proc sort data=aa; by CustID;Run;
proc sort data=bb; by CustID;Run;
data want;
merge aa bb;
by CustID;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Sep 2025 13:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975854#M378196</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-09-27T13:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975859#M378200</link>
      <description>&lt;P&gt;What is the relationship between those datasets?&lt;/P&gt;
&lt;P&gt;One-to-one (as shown in your example)?&lt;/P&gt;
&lt;P&gt;One-to-many/many-to-one?&lt;/P&gt;
&lt;P&gt;Many-to-many?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Sep 2025 13:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975859#M378200</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-27T13:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975861#M378202</link>
      <description>One to one</description>
      <pubDate>Sat, 27 Sep 2025 14:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975861#M378202</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-09-27T14:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975862#M378203</link>
      <description>&lt;P&gt;Then all you need is a DATA step. Expand your MERGE statement like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;merge
  aa
  bb (rename=(y=y_b))
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&amp;nbsp;use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1vjttz6nuankzn1gh4z3wgcu0bf.htm" target="_self"&gt;COALESCE&lt;/A&gt; function to set y.&lt;/P&gt;
&lt;P&gt;In SQL, also use COALESCE (both for aa.custid,bb.custid and aa.y,bb.y).&lt;/P&gt;</description>
      <pubDate>Sat, 27 Sep 2025 14:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975862#M378203</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-27T14:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975871#M378207</link>
      <description>&lt;P&gt;Sound like you want to use UPDATE and not MERGE.&lt;/P&gt;
&lt;P&gt;List the dataset you want to "WIN" last.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aa;
  input CustID y;
cards;
111 .
123 35
222 20
444 50
555 70
;
data bb;
  input CustID y;
cards;
111 15
123 27
222 20
333 35
444 .
666 80
;

data want ;
  update bb aa;
  by custid;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that for both the datasets need to be sorted by the BY variable(s).&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2025 01:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975871#M378207</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-28T01:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975906#M378214</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;, I think this is a good question. I myself feel it is not so easy to figure out the different usage of different conditions for each of them: set, merge, proc sql join/except/corr/all/coalesce&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt; I spend some time and have not figure out which condition I should use which one&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 07:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975906#M378214</guid>
      <dc:creator>dxiao2017</dc:creator>
      <dc:date>2025-09-29T07:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Full Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975926#M378215</link>
      <description>&lt;P&gt;If the tables are already sorted by Custid, use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;s suggestion. Otherwise SQL FULL JOIN is a simple query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;&lt;BR /&gt;   create table want as&lt;BR /&gt;   select coalesce(aa.CustId, bb.Custid) as CustId, &lt;BR /&gt;          coalesce(aa.Y, bb.Y) as Y&lt;BR /&gt;   from aa&lt;BR /&gt;   full join bb&lt;BR /&gt;   on aa.CustId = bb.CustId&lt;BR /&gt;   ;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Sep 2025 08:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Full-Merge/m-p/975926#M378215</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-09-29T08:51:09Z</dc:date>
    </item>
  </channel>
</rss>

