<?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 two datasets in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620681#M182420</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a question with merging two datasets. I want to merge table A with table B and get all the observations in table A that doesn't match with table B. I don't want the matched observations. I have something like this for all matched observations from table A and matching with table B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;DATA matched1; MERGE test1(IN = a) test2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY&amp;nbsp; gender age;&lt;BR /&gt;&amp;nbsp;IF a;&lt;BR /&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this gives all the observations from test1 and those matching from test2. But I want the non-matched one, can I do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;DATA matched1; MERGE test1(IN = a) test2(in=b);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY&amp;nbsp; gender age;&lt;BR /&gt;&amp;nbsp;IF a and not b; &lt;STRONG&gt;/*Not sure if this is the right statement to use in SAS*/&lt;/STRONG&gt;&lt;BR /&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Please advise!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Thank you,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Malathi&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2020 21:59:01 GMT</pubDate>
    <dc:creator>Malathi13</dc:creator>
    <dc:date>2020-01-28T21:59:01Z</dc:date>
    <item>
      <title>Merging two datasets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620681#M182420</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a question with merging two datasets. I want to merge table A with table B and get all the observations in table A that doesn't match with table B. I don't want the matched observations. I have something like this for all matched observations from table A and matching with table B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;DATA matched1; MERGE test1(IN = a) test2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY&amp;nbsp; gender age;&lt;BR /&gt;&amp;nbsp;IF a;&lt;BR /&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this gives all the observations from test1 and those matching from test2. But I want the non-matched one, can I do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;DATA matched1; MERGE test1(IN = a) test2(in=b);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY&amp;nbsp; gender age;&lt;BR /&gt;&amp;nbsp;IF a and not b; &lt;STRONG&gt;/*Not sure if this is the right statement to use in SAS*/&lt;/STRONG&gt;&lt;BR /&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Please advise!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Thank you,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Malathi&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 21:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620681#M182420</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2020-01-28T21:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620687#M182421</link>
      <description>&lt;P&gt;Your second DATA step is correct for what you want. There is no harm in testing it for yourself to see if it gives your the results you want.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 22:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620687#M182421</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-01-28T22:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620751#M182456</link>
      <description>&lt;P&gt;&lt;FONT&gt;if&amp;nbsp; not b ; &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 06:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/620751#M182456</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-01-29T06:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/621305#M182646</link>
      <description>Thank you Ksharp!&lt;BR /&gt;&lt;BR /&gt;M</description>
      <pubDate>Thu, 30 Jan 2020 20:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-in-SAS/m-p/621305#M182646</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2020-01-30T20:21:26Z</dc:date>
    </item>
  </channel>
</rss>

