<?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: Merging two data sets involving duplicating of one of the columns. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305515#M65178</link>
    <description>&lt;P&gt;The above code gave me a cartisian product of the two data sets. Not the result which I &amp;nbsp;was looking for.Thanks anyways.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2016 19:53:41 GMT</pubDate>
    <dc:creator>Ritu_Gowlikar</dc:creator>
    <dc:date>2016-10-18T19:53:41Z</dc:date>
    <item>
      <title>Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305493#M65172</link>
      <description>&lt;P&gt;Hi I have a got two data sets and I have shown them below. I'm trying to merge them by duplicating one of the columns "A " in dataset 1 depending on the number of entries of column "B" in dataset 2 for the same ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset 1 &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;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;xyz&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1245&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1245&lt;/TD&gt;&lt;TD&gt;xya&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;abd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;xyz&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset 2&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;100-1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;112-4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1245&lt;/TD&gt;&lt;TD&gt;116-5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;45-8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;96-7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;152-7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After merging I would like the result to be as follows.&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt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t;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;45-8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;96-7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4567&lt;/TD&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;152-7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the norming merging and interleaving but it doesn't work.&lt;/P&gt;&lt;P&gt;Does it require if the else and do looping to get this result ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 19:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305493#M65172</guid>
      <dc:creator>Ritu_Gowlikar</dc:creator>
      <dc:date>2016-10-18T19:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305501#M65173</link>
      <description>No, just a simple SQL join.</description>
      <pubDate>Tue, 18 Oct 2016 19:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305501#M65173</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-18T19:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305502#M65174</link>
      <description>&lt;P&gt;EDIT - Code corrected - your joining rule has duplicate key values in both input datasets so this is best done with SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as 
  select A.ID
         ,A.A
         ,B.B
   from Dataset1 as A
   inner join Dataset2 as B
   on A.ID = B.ID
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305502#M65174</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-10-18T20:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305515#M65178</link>
      <description>&lt;P&gt;The above code gave me a cartisian product of the two data sets. Not the result which I &amp;nbsp;was looking for.Thanks anyways.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 19:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305515#M65178</guid>
      <dc:creator>Ritu_Gowlikar</dc:creator>
      <dc:date>2016-10-18T19:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305522#M65179</link>
      <description>&lt;P&gt;That looks like it's just a typographical error.&amp;nbsp; Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on A.ID = B.ID&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than that, the logic looks sound.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305522#M65179</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-18T20:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets involving duplicating of one of the columns.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305525#M65180</link>
      <description>&lt;P&gt;Thank you, it worked.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-data-sets-involving-duplicating-of-one-of-the/m-p/305525#M65180</guid>
      <dc:creator>Ritu_Gowlikar</dc:creator>
      <dc:date>2016-10-18T20:18:45Z</dc:date>
    </item>
  </channel>
</rss>

