<?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 with two mutually exclusive different key identifiers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421258#M103635</link>
    <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using sas 9.4 and trying to merge a M&amp;amp;A dataset (DATASET B) with a 60,000 observation with a compustat dataset (DATASET A) with over 800,000 observation. The&amp;nbsp;B dataset has 2 unique identifiers. for the US firm it has CUSIP and for non-us firm it has sedol,&amp;nbsp; and year that I can use for merge. on the other hand, the A&amp;nbsp;dataset has both the identifiers and the year. I was wondering if there is any way that I can merge the two datasets (in a way that dataset&amp;nbsp;A is a left join that keeps all the variables) based on identifier 1 OR identifier 2. meaning use identifier 1 for merge if the&amp;nbsp;B&amp;nbsp;has identifier 1 OR use identifier 2 if the&amp;nbsp;B has identifier 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;This is what I originally used and It absolutely did not work since half of the data has cusip and the other has sedol. Perhaps the data step be a better choice for these type of merging.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;create table mna5 as select unique *&lt;/P&gt;&lt;P&gt;from comp as a left join mna as b&lt;/P&gt;&lt;P&gt;on a.cusip=b.cusip and a.sedol=b.sedol and a.year=b.year;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 14 Dec 2017 17:27:58 GMT</pubDate>
    <dc:creator>Amir8766</dc:creator>
    <dc:date>2017-12-14T17:27:58Z</dc:date>
    <item>
      <title>Merging two datasets with two mutually exclusive different key identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421258#M103635</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using sas 9.4 and trying to merge a M&amp;amp;A dataset (DATASET B) with a 60,000 observation with a compustat dataset (DATASET A) with over 800,000 observation. The&amp;nbsp;B dataset has 2 unique identifiers. for the US firm it has CUSIP and for non-us firm it has sedol,&amp;nbsp; and year that I can use for merge. on the other hand, the A&amp;nbsp;dataset has both the identifiers and the year. I was wondering if there is any way that I can merge the two datasets (in a way that dataset&amp;nbsp;A is a left join that keeps all the variables) based on identifier 1 OR identifier 2. meaning use identifier 1 for merge if the&amp;nbsp;B&amp;nbsp;has identifier 1 OR use identifier 2 if the&amp;nbsp;B has identifier 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;This is what I originally used and It absolutely did not work since half of the data has cusip and the other has sedol. Perhaps the data step be a better choice for these type of merging.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;create table mna5 as select unique *&lt;/P&gt;&lt;P&gt;from comp as a left join mna as b&lt;/P&gt;&lt;P&gt;on a.cusip=b.cusip and a.sedol=b.sedol and a.year=b.year;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 17:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421258#M103635</guid>
      <dc:creator>Amir8766</dc:creator>
      <dc:date>2017-12-14T17:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with two mutually exclusive different key identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421269#M103638</link>
      <description>&lt;P&gt;A couple of short examples of the data that demonstrate the problem would be helpful. A data step to create an example using the variables of interest and the cases that you have and the final desired result would be optimal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be tempted to create a set for matches on cuspid, another from matches on sedol, combine the results and remove duplicates as a crude easy to understand approach.&lt;/P&gt;
&lt;P&gt;Then look for the ones that had no matches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 17:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421269#M103638</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-14T17:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with two mutually exclusive different key identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421298#M103649</link>
      <description>&lt;P&gt;Would this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on (a.cusip=b.cusip or a.sedol=b.sedol) and a.year=b.year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 18:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-two-mutually-exclusive-different-key/m-p/421298#M103649</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-14T18:57:03Z</dc:date>
    </item>
  </channel>
</rss>

