<?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: Many-to-many merge in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673856#M23515</link>
    <description>&lt;P&gt;You can combine same name columns with COALESCE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table both as 
 select 
	coalesce(a.id. b.id) as id,
	color,
	coalesce(a.animal, b.animal) as animal,
	farm
 from 
	one as a full join 
	two as b on a.id = b.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you have nonmissing animal values in both tables, you will only get the value from table one.&lt;/P&gt;</description>
    <pubDate>Sat, 01 Aug 2020 01:41:46 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-08-01T01:41:46Z</dc:date>
    <item>
      <title>Many-to-many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673849#M23512</link>
      <description>&lt;P&gt;My apologies if this has already been answered on here and I didn't see it, but I have two tables that I'd like to do a many-to-many merge on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;                  
  input id $ color $ animal $ farm $;      
datalines;                 
a blue . .
a black . .
d green . .
;                          
run;
 
data two;                  
  input id $ animal $;      
datalines;                 
a turtle
a snake
b cat
b cow
c bird
c horse
;      
run; 

data want;                  
  input id $ color $ animal $ farm $;      
datalines;  
a blue turtle .
a blue snake .
a black turtle .
a black snake .
b . cat .
b . cow .
c . bird .
c . horse .
d green . .
;      
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried the following, but it doesn't yield the same results as the "want" table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table both
  as select * from one as a
   full join two as b
    on a.id = b.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any suggestions would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 00:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673849#M23512</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-08-01T00:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Many-to-many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673852#M23513</link>
      <description>&lt;P&gt;1) Merging many to many, will create line&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;a black snake .&lt;/PRE&gt;
&lt;P&gt;and not&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;b black snake .&lt;/PRE&gt;
&lt;P&gt;as shown in wanted data, because snake has ID=a.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Your code need a slight change to work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table both
  as select a.* , b.*
      from one as a
     full join two as b
    on a.id = b.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Aug 2020 00:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673852#M23513</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-01T00:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Many-to-many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673853#M23514</link>
      <description>Thank you, you're right. That was a typo - I edited the post.&lt;BR /&gt;&lt;BR /&gt;When I run your code, none of the records where id = "b" or id = "c" are there, and all of the ANIMAL values are blank.</description>
      <pubDate>Sat, 01 Aug 2020 00:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673853#M23514</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-08-01T00:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Many-to-many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673856#M23515</link>
      <description>&lt;P&gt;You can combine same name columns with COALESCE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table both as 
 select 
	coalesce(a.id. b.id) as id,
	color,
	coalesce(a.animal, b.animal) as animal,
	farm
 from 
	one as a full join 
	two as b on a.id = b.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you have nonmissing animal values in both tables, you will only get the value from table one.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 01:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673856#M23515</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-08-01T01:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Many-to-many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673857#M23516</link>
      <description>That worked, thank you!</description>
      <pubDate>Sat, 01 Aug 2020 01:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Many-to-many-merge/m-p/673857#M23516</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-08-01T01:45:30Z</dc:date>
    </item>
  </channel>
</rss>

