<?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 Merging Tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/580772#M165000</link>
    <description>&lt;P&gt;data inter1;&lt;BR /&gt;merge np_species_sorted(in=in1) np_codelookup_sorted(in=in2);&lt;BR /&gt;by ParkCode;&lt;BR /&gt;keep ParkCode Category ParkName;&lt;BR /&gt;if in1=1 and in2=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data inter1;&lt;BR /&gt;merge np_species_sorted(in=in1) np_codelookup_sorted(in=in2);&lt;BR /&gt;by ParkCode;&lt;BR /&gt;keep ParkCode Category ParkName;&lt;BR /&gt;if in1=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me understand the difference between the two code snippets?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2019 12:31:02 GMT</pubDate>
    <dc:creator>primukh26</dc:creator>
    <dc:date>2019-08-13T12:31:02Z</dc:date>
    <item>
      <title>Merging Tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/580772#M165000</link>
      <description>&lt;P&gt;data inter1;&lt;BR /&gt;merge np_species_sorted(in=in1) np_codelookup_sorted(in=in2);&lt;BR /&gt;by ParkCode;&lt;BR /&gt;keep ParkCode Category ParkName;&lt;BR /&gt;if in1=1 and in2=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data inter1;&lt;BR /&gt;merge np_species_sorted(in=in1) np_codelookup_sorted(in=in2);&lt;BR /&gt;by ParkCode;&lt;BR /&gt;keep ParkCode Category ParkName;&lt;BR /&gt;if in1=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me understand the difference between the two code snippets?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 12:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/580772#M165000</guid>
      <dc:creator>primukh26</dc:creator>
      <dc:date>2019-08-13T12:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merging Tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/580781#M165003</link>
      <description>&lt;P&gt;in the first code, you request only observations where both&amp;nbsp;&lt;SPAN&gt;np_species_sorted and&amp;nbsp;np_codelookup_sorted contribute with&amp;nbsp;ParkCode. In SQL terms this is the same as an inner join.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the second code, you request observations where&amp;nbsp;np_species_sorted contribute, but not necessarily&amp;nbsp;np_codelookup_sorted. Consequently, you might see missing values for the variables that&amp;nbsp;np_codelookup_sorted contribute with. This is a left join in SQl terms.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please ask if you want a deeper explanation &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 12:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/580781#M165003</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-13T12:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merging Tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581922#M165436</link>
      <description>&lt;P&gt;Thanks for the explanation&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 12:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581922#M165436</guid>
      <dc:creator>primukh26</dc:creator>
      <dc:date>2019-08-17T12:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merging Tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581923#M165437</link>
      <description>&lt;P&gt;Anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 12:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581923#M165437</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-17T12:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging Tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581931#M165438</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; To help you understand all the possibilities, this code illustrates how a SAS merge can generate multiple output tables with one pass through the data using IN= variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mtable1;
  infile datalines;
  input commonvar amount;
  return;
  datalines;
11 115
13 315
14 415
16 615
;
run;

data mtable2;
  infile datalines;
  input commonvar name $ zip $;
return;
datalines;
10 Alicia 12345
11 Bryce 23456
12 Carolyn 34567
13 David 45678
14 Elsa 56789
15 Fern 67890
;
run;

data both oneonly twoonly allofone alloftwo;
  merge mtable1(in=inone) mtable2(in=intwo);
  by commonvar;
  if inone=1 then do;
     output allofone;
     if inone=1 and intwo=1 then output both;
     else if inone=1 and intwo=0 then output oneonly;
  end;
  if intwo=1 then do;
     output alloftwo;
     if intwo=1 and inone=0 then output twoonly;
  end;
run;

proc print data=both;
  title 'BOTH';
run;

proc print data=oneonly;
  title 'ONEONLY';
run;

proc print data=twoonly;
  title 'TWOONLY';
run;

proc print data=allofone;
  title 'ALLOFONE';
run;

proc print data=alloftwo;
  title 'ALLOFTWO';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 13:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Tables/m-p/581931#M165438</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-08-17T13:33:33Z</dc:date>
    </item>
  </channel>
</rss>

