<?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: is this merge one to many,many to one or many to many? and how does it work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671194#M201519</link>
    <description>&lt;P&gt;The attached deck shows how merge works&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 19:45:43 GMT</pubDate>
    <dc:creator>smantha</dc:creator>
    <dc:date>2020-07-21T19:45:43Z</dc:date>
    <item>
      <title>is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671110#M201489</link>
      <description>&lt;P&gt;data GroupA; input ID$ Product$; datalines; A Apple B Grapes B Orange C Banana E Apple run; data GroupB; input ID$ Product$ Size$; datalines; B Shirt S C Pants M D Jacket L E Tie M E Wallet L run; can someone please explain elaborately why does b grapes c banana e apple doesnt come in the output table data merged; merge GroupA GroupB; by ID; run; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33307"&gt;@AnnaBrown&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 16:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671110#M201489</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-21T16:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671132#M201498</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;</description>
      <pubDate>Tue, 21 Jul 2020 17:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671132#M201498</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-21T17:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671139#M201502</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319930"&gt;@veda8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data GroupA; input ID$ Product$; datalines; A Apple B Grapes B Orange C Banana E Apple run; data GroupB; input ID$ Product$ Size$; datalines; B Shirt S C Pants M D Jacket L E Tie M E Wallet L run; can someone please explain elaborately why does b grapes c banana e apple doesnt come in the output table data merged; merge GroupA GroupB; by ID; run; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33307"&gt;@AnnaBrown&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post the code in a code box opened with either the &amp;lt;/&amp;gt; or "running man" icon. Looking at code like that makes my head hurt.&lt;/P&gt;
&lt;P&gt;Better, post the LOG of what you get when you run the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can only have one variable of a given name in a data set. When you have&amp;nbsp; the same variable other than the the BY variable(s) in both sets, only one of the values ends up in the output, typically the one from the right most data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the name of the Product variable in one of the sets and you can see what goes on a bit better.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 17:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671139#M201502</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-21T17:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671162#M201505</link>
      <description>&lt;P&gt;Use the proper subwindows for posting code and logs.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 18:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671162#M201505</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-21T18:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671192#M201517</link>
      <description>&lt;P&gt;Following is how a data step merge works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Build a pdv of all common variables (imagine an array with one slot per each unique variable across the datasets)&lt;/P&gt;
&lt;P&gt;2. SAS looks at the set or merge statement . If set statement and there are multiple datasets it will process all rows from each of the datasets in teh order in which it is specified .&lt;/P&gt;
&lt;P&gt;3. if there is a merge statement with a by and the datasets are sorted Then it will&amp;nbsp; &amp;nbsp;read a row from first data set and read a row from second dataset checks if order wise the by variables align. If by variables align then it will read all variables from first dataset and populates the pdv. Then it will read all the values from the second dataset. If the overlapping values are non missing then it will overwrite the values in the pdv. Then the pointer is moved to the next record on the first dataset and the same happens on the second dataset . The pdv is not flushed yet. Once it is determined that the by variables are different in both the datasets then pdv is flushed and the process repeats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case or atleast in your example you do not have many to many joins. Your case is a simple overwrite as explained above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg of 1 -1 join: there is only unique entry for each variable combination on the by statement in two datasets&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 - many join&amp;nbsp; there is only unique entry for each variable combination on the by statement in one of the two datasets and there is a duplicate entry in the other.&lt;/P&gt;
&lt;P&gt;many-many join:&amp;nbsp; there are duplicate entries for each variable combination on the by statement in two datasets&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 19:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671192#M201517</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-21T19:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671194#M201519</link>
      <description>&lt;P&gt;The attached deck shows how merge works&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 19:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671194#M201519</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-21T19:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: is this merge one to many,many to one or many to many? and how does it work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671548#M201678</link>
      <description>&lt;P&gt;This video tutorial on merging data sets in SAS using SQL may be something to consider as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fdhf747bz_nE%3Flist%3DPLVV6eZFA22QwrXd6nSDU18E6XgXSMOs87&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Ddhf747bz_nE&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fdhf747bz_nE%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="600" height="337" scrolling="no" title="SAS Tutorial | Merging Data Sets in SAS using SQL" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 19:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-this-merge-one-to-many-many-to-one-or-many-to-many-and-how/m-p/671548#M201678</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2020-07-22T19:03:46Z</dc:date>
    </item>
  </channel>
</rss>

