<?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: datasets match merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/353012#M273822</link>
    <description>&lt;P&gt;I would check both datasets for duplicates. You don't say anywhere that there are no duplicate records.&amp;nbsp; Duplicate records can make a mess out of matching.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2017 21:12:31 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2017-04-24T21:12:31Z</dc:date>
    <item>
      <title>datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352708#M273812</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an exercise for a class that requires me to merge 2 datasets and I don't think I am getting it right.&lt;/P&gt;&lt;P&gt;The first dataset is class.excel1 with 1166 observations and 28 variables,&amp;nbsp;and second dataset is class.excel2 with 882 observation and 9 variables.&lt;/P&gt;&lt;P&gt;Both dataset have a common variable called "serial_number" and I am suppose to merge the 2 dataset by this variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;class.excel1 (the bigger dataset) should contain all the serial_number that class.excel2 (the smaller dataset) has, and my goal is the to match the serial_number between the 2 datasets and only keep those observations that the serial_number matched.&lt;/P&gt;&lt;P&gt;Right now my code is (after sorting by serial_number):&lt;/P&gt;&lt;P&gt;data class.merge;&lt;/P&gt;&lt;P&gt;merge class.excel1 class.excel2;&lt;/P&gt;&lt;P&gt;by serial_number;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log says:&lt;/P&gt;&lt;P&gt;The data set class.merge has 1476 observations and 36 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, there should be only 882 observations or less, so there must be something off and I am not sure what went wrong and how to fix it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any advice is appreciated! Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352708#M273812</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-24T04:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352710#M273813</link>
      <description>&lt;P&gt;Use the IN option to make sure a record is in both datasets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p02xs0q9ihz3k1n1jfmzhy0sk1cw.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p02xs0q9ihz3k1n1jfmzhy0sk1cw.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352710#M273813</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-24T04:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352711#M273814</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class.merge;
merge class.excel1(in=a) class.excel2(in=b);
by serial_number;
if a and b;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352711#M273814</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-24T04:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352712#M273815</link>
      <description>&lt;P&gt;Thank you. But I did try that:&lt;/P&gt;&lt;P&gt;data class.merge;&lt;/P&gt;&lt;P&gt;merge class.excel1 class.excel2 (in=frodo);&lt;/P&gt;&lt;P&gt;by serial_number;&lt;/P&gt;&lt;P&gt;if frodo;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and log says I have 1166 observations and 36 variables.&lt;/P&gt;&lt;P&gt;Is my in option not quite right?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352712#M273815</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-24T04:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352713#M273816</link>
      <description>It means that there are multiple records by the same serial_number in class.excel1 due to which you are getting all of them into class.merge.</description>
      <pubDate>Mon, 24 Apr 2017 04:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352713#M273816</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-24T04:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352714#M273817</link>
      <description>&lt;P&gt;I see! thank you so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;So I need the in option for both datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have now 654 observations and 36 variables.&lt;/P&gt;&lt;P&gt;However, another classmate of mine used R to merge and he only got 6 observations that did not match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to print a list of observations that were not matched?&lt;/P&gt;&lt;P&gt;much appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352714#M273817</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-24T04:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352715#M273818</link>
      <description>&lt;P&gt;Rather than using IN to filter use it to create a flag.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;set data1 (in=a) data2(in=b);&lt;/P&gt;
&lt;P&gt;length flag $8.;&lt;/P&gt;
&lt;P&gt;if a and b then flag ='MATCH';&lt;/P&gt;
&lt;P&gt;Else if a then flag = 'A';&lt;/P&gt;
&lt;P&gt;else if b then flag = 'B';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352715#M273818</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-24T04:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352716#M273819</link>
      <description>If b and not a;&lt;BR /&gt;&lt;BR /&gt;This will give the observation that did not match.</description>
      <pubDate>Mon, 24 Apr 2017 04:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352716#M273819</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-04-24T04:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352719#M273820</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352719#M273820</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-24T04:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352720#M273821</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;! This is life changing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 04:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/352720#M273821</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-24T04:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: datasets match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/353012#M273822</link>
      <description>&lt;P&gt;I would check both datasets for duplicates. You don't say anywhere that there are no duplicate records.&amp;nbsp; Duplicate records can make a mess out of matching.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 21:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-match-merging/m-p/353012#M273822</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-04-24T21:12:31Z</dc:date>
    </item>
  </channel>
</rss>

