<?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: One-to-one merge and then force out in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15640#M2765</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a bunch of rules that you have to integrate, to see why this works.&amp;nbsp; Basically, they center around how and when IN= variables get set, and how MERGE works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. IN= variables get set to 0 when beginning a new BY value (in this case, a new ID).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. IN= variables get set to 1 when reading an observation from the source data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. MERGE reads each observation only once.&amp;nbsp; In a many-to-one MERGE, the observation gets read once from the "one" data set, and retained.&amp;nbsp; It does not get re-read as additional observations get read from the other data set, for the same ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. You are allowed to refer to IN= variables in your programming statements, including setting the values as is done here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, put these all together.&amp;nbsp; Here is just one example.&amp;nbsp; When A contains multiple records for an ID, but B contains only one, the software sets both IN= variables to 0 as it begins a new ID.&amp;nbsp; It reads the first observation from A, and sets INA to 1.&amp;nbsp; Then it reads the first (and only) observation from B, and sets inB to 1.&amp;nbsp; That first observation passes the subsetting IF test, and gets output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, the programming statements set both IN= variables to 0.&amp;nbsp; The software reads the second observation from A, and sets INA to 1.&amp;nbsp; It reads nothing from B, since there is no second observation for the current ID.&amp;nbsp; So INB remains 0.&amp;nbsp; That observation does not pass the subsetting IF test, and gets deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is all clear.&amp;nbsp; The programming looks simple, but it takes advantage of a complex process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Nov 2012 16:05:03 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-11-12T16:05:03Z</dc:date>
    <item>
      <title>One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15626#M2751</link>
      <description>I have two datasets A and B.&lt;BR /&gt;
&lt;BR /&gt;
Multiple records from A could merge to same record in B.&lt;BR /&gt;
&lt;BR /&gt;
I want to merge A with B such that if the first record from A merges with first record from B, I want to make the first record from B unavailable for merging with second record from A, even if it can merge.&lt;BR /&gt;
&lt;BR /&gt;
For example, lets say A has 2 records (1 &amp;amp; 2) and B has 2 records (3 &amp;amp; 4). Based on the variables that I'm merging on, both the records from A can merge with both the records from B.&lt;BR /&gt;
&lt;BR /&gt;
I want to merge 1 with 3 and then make 3 unavilable (or force out of the database) so that 2 can merge with 4.&lt;BR /&gt;
&lt;BR /&gt;
I've resolved the issue using lag approach, however, I'm interested in using merge approach.&lt;BR /&gt;
&lt;BR /&gt;
Please share your ideas.</description>
      <pubDate>Wed, 11 Nov 2009 19:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15626#M2751</guid>
      <dc:creator>Sas_Geek</dc:creator>
      <dc:date>2009-11-11T19:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15627#M2752</link>
      <description>from the simple data example you provided, seems that you may use line-by-line merge, which means line 1 in A merge with line1 in B, line 2 in A merge with line 2 in B, etc. I will not recommend this though, since data could be much more complicated. the more robust way, I think, may be adding more variable as key for merging. For example, you may create a count variable to record No. 1, 2, 3 record in A under your merging by variable, and do same to B, and add this count variable to the merging by variable list.</description>
      <pubDate>Wed, 11 Nov 2009 20:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15627#M2752</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-11T20:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15628#M2753</link>
      <description>I think that you will find that several of us are having trouble figuring out exactly what you are asking.  Perhaps a more robust example would help.</description>
      <pubDate>Wed, 11 Nov 2009 20:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15628#M2753</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-11-11T20:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15629#M2754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have 2 datasets - dataset A and B, as shown below. When I merge by ID, I get the resulting dataset, also shown below. What I would like to have, is for record 1 in dataset A to merge with record_ 3 in dataset B, and record 2 with record_ 4, so that record 1 doesn't go ahead and merge with record_ 4, and record_ 3 is not available for merging with record 2. This is shown below in "Desired Merged Dataset".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="360"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl64" colspan="3" height="17" width="216"&gt;Dataset A&lt;/TD&gt;&lt;TD width="72"&gt;&lt;/TD&gt;&lt;TD width="72"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;Record&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ID&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" colspan="3" height="17"&gt;Dataset B&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;Record_&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ID&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty_&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;TD class="xl63"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" colspan="5" height="17"&gt;Resulting Merged Dataset&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ID&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Record&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Record_&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty_&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" colspan="5" height="17"&gt;Desired Merged Dataset&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ID&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Record&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Record_&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;Qty_&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;ABC&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15629#M2754</guid>
      <dc:creator>Sas_Geek</dc:creator>
      <dc:date>2012-09-27T20:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15630#M2755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess what you did is SQL "join" instead of data step "merge", so here is the merge:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data A;&lt;/P&gt;&lt;P&gt;input Record&amp;nbsp;&amp;nbsp;&amp;nbsp; ID:$&amp;nbsp;&amp;nbsp;&amp;nbsp; Qty;&lt;/P&gt;&lt;P&gt;cards;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Data B;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;input Record_&amp;nbsp;&amp;nbsp;&amp;nbsp; ID:$&amp;nbsp;&amp;nbsp;&amp;nbsp; Qty_;&lt;/P&gt;&lt;P&gt;cards;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c;&lt;/P&gt;&lt;P&gt;merge a b;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 23:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15630#M2755</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-27T23:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15631#M2756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are searching the MERGE statement without BY .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c;&lt;/P&gt;&lt;P&gt;merge a b;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 02:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15631#M2756</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-09-28T02:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15632#M2757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If both tables have same amount of obs, then "merge without by" = "set; set;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c;&lt;/P&gt;&lt;P&gt;set a;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 02:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15632#M2757</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-28T02:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15633#M2758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. I agree that your suggestions would achieve the desired outcome when there are equal no. of observation per ID in the datasets. However, in my case, the dataset may not have same amount of observations for all IDs, see for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 216px;"&gt;&lt;TBODY&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" colspan="3" height="17" style="font-style: inherit;" width="216"&gt;Dataset A&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;Record&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;Qty&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;ABC&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;2&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;EFG&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;3&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;MNO&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;4&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;MNO&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;5&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;6&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt; &lt;/TD&gt;&lt;TD class="xl63" width="72"&gt; &lt;/TD&gt;&lt;TD class="xl63" width="72"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" colspan="3" height="17" style="font-style: inherit;" width="216"&gt;Dataset B&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit;"&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;Record_&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;Qty_&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;7&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;ABC&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="font-style: inherit;" width="72"&gt;8&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;ABC&lt;/TD&gt;&lt;TD class="xl63" style="font-style: inherit;" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;9&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;MNO&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;10&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;PQR&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;11&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="72"&gt;10&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl63" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The desired outcome is a merged dataset with following pairs:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="360"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="font-style: inherit;" width="72"&gt;ID&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;Record&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;Record_&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;Qty&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;Qty_&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="font-style: inherit;" width="72"&gt;ABC&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;1&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;7&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;30&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="font-style: inherit;" width="72"&gt;MNO&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;3&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;9&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;30&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;5&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;11&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;30&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="font-style: inherit;" width="72"&gt;XYZ&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;6&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;10&lt;/TD&gt;&lt;TD class="xl65" style="font-style: inherit;" width="72"&gt;30&lt;/TD&gt;&lt;TD class="xl65" width="72"&gt;-30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 07:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15633#M2758</guid>
      <dc:creator>Sas_Geek</dc:creator>
      <dc:date>2012-10-01T07:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15634#M2759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need something Special . It is from Tom .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data A;
input Record&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ Qty;
cards;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EFG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30
;
run;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
data B;
input Record_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ID $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qty_;
cards;
7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PQR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-30
;
run;
data want;
ina=0;inb=0;
 merge a(in=ina) b(in=inb);
 by id;
 if ina and inb;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 13:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15634#M2759</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-10-01T13:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15635#M2760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome! Exactly what I was looking for. Thanks, Ksharp!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a Proc Sql equivalent of this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 16:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15635#M2760</guid>
      <dc:creator>Sas_Geek</dc:creator>
      <dc:date>2012-10-01T16:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15636#M2761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it is hard for SQL. Even sql can do that, there must be lots of sql statements.&lt;/P&gt;&lt;P&gt;Do you have to use SQL ? Why not simple MERGE statement ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 06:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15636#M2761</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-10-02T06:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15637#M2762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe OP needs something in Pass-through. I agree with Ksharp, it seems impossible for SQL, which is not designed for sequential process. It is already a bit unconventional approach (or as we often call it wicked &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; for Tom's ingenious solution) even for data step merge. Here is an option I believe still within the normal range of Hash() implementation, and if I may, no sort needed.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; A;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Record&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $ Qty;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EFG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; B;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Record_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Qty_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MNO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PQR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _n_=&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; b;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; hash b(dataset:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;'b'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;, multidata:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;'y'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.definekey(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;'id'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.definedata(all:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;'y'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.definedone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; rc=b.find();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; rc=&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc=b.removedup();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 13:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15637#M2762</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-10-02T13:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15638#M2763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I agree. A simple merge statement should be fine for this purpose. I anyways will need to sort the data by ID and date. Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 12:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15638#M2763</guid>
      <dc:creator>Sas_Geek</dc:creator>
      <dc:date>2012-10-04T12:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15639#M2764</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 guess this whole logic is working because of the highlighted options below.&lt;/P&gt;&lt;P&gt;Could you please explain the use of this ????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ina=0;inb=0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; merge a(in=ina) b(in=inb);&lt;/P&gt;&lt;P&gt; by id;&lt;/P&gt;&lt;P&gt; if ina and inb;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2012 15:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15639#M2764</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-11-12T15:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15640#M2765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a bunch of rules that you have to integrate, to see why this works.&amp;nbsp; Basically, they center around how and when IN= variables get set, and how MERGE works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. IN= variables get set to 0 when beginning a new BY value (in this case, a new ID).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. IN= variables get set to 1 when reading an observation from the source data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. MERGE reads each observation only once.&amp;nbsp; In a many-to-one MERGE, the observation gets read once from the "one" data set, and retained.&amp;nbsp; It does not get re-read as additional observations get read from the other data set, for the same ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. You are allowed to refer to IN= variables in your programming statements, including setting the values as is done here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, put these all together.&amp;nbsp; Here is just one example.&amp;nbsp; When A contains multiple records for an ID, but B contains only one, the software sets both IN= variables to 0 as it begins a new ID.&amp;nbsp; It reads the first observation from A, and sets INA to 1.&amp;nbsp; Then it reads the first (and only) observation from B, and sets inB to 1.&amp;nbsp; That first observation passes the subsetting IF test, and gets output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, the programming statements set both IN= variables to 0.&amp;nbsp; The software reads the second observation from A, and sets INA to 1.&amp;nbsp; It reads nothing from B, since there is no second observation for the current ID.&amp;nbsp; So INB remains 0.&amp;nbsp; That observation does not pass the subsetting IF test, and gets deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is all clear.&amp;nbsp; The programming looks simple, but it takes advantage of a complex process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2012 16:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15640#M2765</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-11-12T16:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15641#M2766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the quick and detailed response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Karun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2012 16:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15641#M2766</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-11-12T16:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: One-to-one merge and then force out</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15642#M2767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding is a good one .Have already given you a detail explanation .&lt;/P&gt;&lt;P&gt;I just want give an example to demonstrate it .&lt;/P&gt;&lt;P&gt;For each of data step iteration , I set ina=0 and inb=0. when this obs belong to A or B, ina or inb will be set 1 respectively .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;id&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ina&amp;nbsp;&amp;nbsp; inb&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you didn't set ina=0 and inb=0, then both of them will always be 1 until reaching the next BY group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 05:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/One-to-one-merge-and-then-force-out/m-p/15642#M2767</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-11-13T05:16:07Z</dc:date>
    </item>
  </channel>
</rss>

