<?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 join in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821637#M41014</link>
    <description>&lt;P&gt;For a many-to-many you probably want to use SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select * 
  from DATASET_A a 
  full join DATASET_B b
    on a.JoinKey = b.JoinKey
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Jul 2022 15:47:01 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-05T15:47:01Z</dc:date>
    <item>
      <title>Many to Many join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821628#M41012</link>
      <description>&lt;P&gt;Good Afternoon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets which I need to merge together with a primary key common to both. However, I need all possible combinations of joins.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example - Dataset A has various different mortgage transactions associated with people over n number of years.&lt;/P&gt;&lt;P&gt;Dataset B&amp;nbsp; - has various different property transactions associated with people over n number of years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can merge dataset A and B together based on a primary key (JoinKey) but the issue is that when there are many different potential matches they do not come out. As you see from below for JoinKey 2 there is basically 4 different properties matched to 4 different mortgages but in truth I need all potential 16 matches here - 4*4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to merge this in SAS so any help would be welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;JoinKey&lt;/TD&gt;&lt;TD&gt;Property_Key (Dataset B)&lt;/TD&gt;&lt;TD&gt;Mortgage Key (Dataset A)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20003B-1&lt;/TD&gt;&lt;TD&gt;010009P-452638dd4fe80bc6f1b0d2deac075492d7a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20003B-1&lt;/TD&gt;&lt;TD&gt;010009P-7454787243c7260e21563f7998fef1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;12005V-1&lt;/TD&gt;&lt;TD&gt;011434X-a8687f0496365442dbda99ca74e&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2102H-1&lt;/TD&gt;&lt;TD&gt;011434X-adc35318d5f0e&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1208B-1&lt;/TD&gt;&lt;TD&gt;011434X-bd5b206ada728f18e7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1501V-1&lt;/TD&gt;&lt;TD&gt;011434X-c3601e9a24c8d7319ea1b&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 15:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821628#M41012</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2022-07-05T15:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Many to Many join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821636#M41013</link>
      <description>&lt;P&gt;A cartesian join is best done in SQL; in a data step it needs additional coding.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
input key x;
datalines;
1 1
1 2
;

data have2;
input key y;
datalines;
1 3
1 4
;

proc sql;
create table want as
  select
    h1.key,
    h1.x,
    h2.y
  from have1 h1 full join have2 h2
  on h1.key = h2.key
;
quit;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;key	x	y
1	1	3
1	1	4
1	2	3
1	2	4
&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 15:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821636#M41013</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-05T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Many to Many join</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821637#M41014</link>
      <description>&lt;P&gt;For a many-to-many you probably want to use SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select * 
  from DATASET_A a 
  full join DATASET_B b
    on a.JoinKey = b.JoinKey
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 15:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Many-to-Many-join/m-p/821637#M41014</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-05T15:47:01Z</dc:date>
    </item>
  </channel>
</rss>

