<?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: MERGE in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174870#M44901</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the encounter repeats in both data sources, there will still be a duplicate entry in your merged data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input encounter fakedata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input encounter fakedata2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 3&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;1 5&lt;/P&gt;&lt;P&gt;1 6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tester;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge one two;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by encounter;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data step merge does NOT support many to many appropriately and still will manage one-to-many without failing output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you notice the TESTER result, this is what happens: starting with the first record for a by variable in each dataset, merges 1:1 until either data set runs out of records for the by group at which points the last value is retained and output with all subsequent records from the other source that have the same by value. Hence this does by no mean kill duplicates from either set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in short, no it does not solve your issue. At least not how you've worded it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Dec 2013 21:47:38 GMT</pubDate>
    <dc:creator>Vince28_Statcan</dc:creator>
    <dc:date>2013-12-16T21:47:38Z</dc:date>
    <item>
      <title>MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174869#M44900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am pulling info from two datasets(sources) and i am suspecting some common records(repeats) by the encounters variable.&lt;/P&gt;&lt;P&gt;we need to count only once when there are repeats&lt;/P&gt;&lt;P&gt;Can we do the simple merge step like shown below?????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*DOES THIS TESTER DATASET GIVE EXCLUSIVES TO EACH OF THE TWO DATASETS AND ALSO THE COMMONS&lt;BR /&gt;data tester;========getting 193&lt;BR /&gt;merge one two;&lt;BR /&gt;by encounters;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When&amp;nbsp; i split the data i am getting like this...........total number here match the count we get above&lt;/P&gt;&lt;P&gt;data test1 test2 test3;&lt;/P&gt;&lt;P&gt;merge one(in=a) two(in=b);&lt;/P&gt;&lt;P&gt;by encounters;&lt;/P&gt;&lt;P&gt;if a and not b then output test1;========62&lt;/P&gt;&lt;P&gt;if b and not a then output test2;========48&lt;/P&gt;&lt;P&gt;if a and b then output test3;============83&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Dec 2013 20:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174869#M44900</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-12-16T20:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174870#M44901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the encounter repeats in both data sources, there will still be a duplicate entry in your merged data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input encounter fakedata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input encounter fakedata2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 3&lt;/P&gt;&lt;P&gt;1 4&lt;/P&gt;&lt;P&gt;1 5&lt;/P&gt;&lt;P&gt;1 6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tester;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge one two;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by encounter;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data step merge does NOT support many to many appropriately and still will manage one-to-many without failing output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you notice the TESTER result, this is what happens: starting with the first record for a by variable in each dataset, merges 1:1 until either data set runs out of records for the by group at which points the last value is retained and output with all subsequent records from the other source that have the same by value. Hence this does by no mean kill duplicates from either set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in short, no it does not solve your issue. At least not how you've worded it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Dec 2013 21:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174870#M44901</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-12-16T21:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174871#M44902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the question?&lt;/P&gt;&lt;P&gt;If you want to count unique values of ENCOUNTERS?&amp;nbsp; Overall and by each dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if eof then put n= a= b= ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;merge one(in=in1) two(in=in2) end=eof;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by encounters;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if first.encounters then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; n+1;a+in1; b+in2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;end;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Dec 2013 22:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174871#M44902</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-12-16T22:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174872#M44903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think I put it in wrong words.....&lt;/P&gt;&lt;P&gt;when I meant repeats ...........I mean the same encounter&amp;nbsp; is present in&amp;nbsp; source1 and also source 2 .&lt;/P&gt;&lt;P&gt;I mean if we set those two datasets we would have repeats by encounters&lt;/P&gt;&lt;P&gt;so I was asking if the simple merge I showed would bring up exclusive encounters to both as well as common to both???????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in total I was wondering if it would bring up the unique records from both the datasets???????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 00:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174872#M44903</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-12-17T00:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174873#M44904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If each individual file does not have duplicates then the example you showed will separate them into the three possible groups.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 02:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174873#M44904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-12-17T02:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174874#M44905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If counting the number of duplicate row in a table can help you then please try it.&lt;/P&gt;&lt;P&gt;It will generate an output column that shows how many times each row occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;/P&gt;&lt;P&gt;select * , count (*) as count &lt;/P&gt;&lt;P&gt;from DSN&lt;/P&gt;&lt;P&gt;group by var1, var2&lt;/P&gt;&lt;P&gt;having count (*) &amp;gt;1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uma Shanker Saini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Dec 2013 09:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MERGE/m-p/174874#M44905</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2013-12-17T09:19:16Z</dc:date>
    </item>
  </channel>
</rss>

