<?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 DataSets match MERGE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302400#M64148</link>
    <description>&lt;P&gt;It is possible to match Datasets using differents variables with merge?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have 3 DataSets (DS):&lt;/P&gt;&lt;P&gt;DS1 and DS2 can be matched by var1&lt;/P&gt;&lt;P&gt;DS2 and DS3 only by Var2 (Var2 has differente data than Var1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that is possible in diferent data steps or using proc SQL, but I want to know if is possible with merge in one step or exists other method using SAS code.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2016 16:50:11 GMT</pubDate>
    <dc:creator>Angel_Saenz</dc:creator>
    <dc:date>2016-10-04T16:50:11Z</dc:date>
    <item>
      <title>DataSets match MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302400#M64148</link>
      <description>&lt;P&gt;It is possible to match Datasets using differents variables with merge?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have 3 DataSets (DS):&lt;/P&gt;&lt;P&gt;DS1 and DS2 can be matched by var1&lt;/P&gt;&lt;P&gt;DS2 and DS3 only by Var2 (Var2 has differente data than Var1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that is possible in diferent data steps or using proc SQL, but I want to know if is possible with merge in one step or exists other method using SAS code.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 16:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302400#M64148</guid>
      <dc:creator>Angel_Saenz</dc:creator>
      <dc:date>2016-10-04T16:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: DataSets match MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302413#M64155</link>
      <description>&lt;P&gt;MERGE won't do that at all.&amp;nbsp; You can force a DATA step to do what you are asking, but it is not necessarily simple.&amp;nbsp; And the complexities multiply if you have a possibility of mismatches or a possiblity of a many-to-one (or worse yet, many-to-many) match.&amp;nbsp; Here are a couple of ideas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create an index for one data set.&amp;nbsp; Merge the other two, and in the same DATA step use SET with KEY= to retrieve the matching data.&lt;/LI&gt;
&lt;LI&gt;Create a hash table from one data set.&amp;nbsp; Merge the other two, and in the same DATA step look up matching information in the hash table.&lt;/LI&gt;
&lt;LI&gt;Create a format that maps from one of your BY variables to the observation number that holds a unique value for that BY variable.&amp;nbsp; Then in a DATA step, merge the other two data sets and use the format to locate the matching observation from the third data set.&amp;nbsp; Use SET with POINT= to retrieve the matching information.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In terms of speed and simplicity, I would probably go with the hash table.&amp;nbsp; But nothing is simple.&amp;nbsp; For example, what should happen if the hash table contains a data value that does not have a match either of the other two data sets?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 17:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302413#M64155</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-04T17:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: DataSets match MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302466#M64159</link>
      <description>&lt;P&gt;Proc SQL is the exact tool for that task. Be aware however that for many-to-many merges it is not equivalent to the data step.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 20:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302466#M64159</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-04T20:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: DataSets match MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302517#M64177</link>
      <description>&lt;P&gt;Since you can only have one BY statement in the data step, this is not possible.&lt;/P&gt;
&lt;P&gt;Use SQL for doing that in one step. But be aware that joining multiple &lt;U&gt;large&lt;/U&gt; tables in SQL will often perform horribly compared to a sequence of SORT and MERGE steps.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 05:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DataSets-match-MERGE/m-p/302517#M64177</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-05T05:47:54Z</dc:date>
    </item>
  </channel>
</rss>

