<?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 many merge in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/one-to-many-merge/m-p/628884#M20685</link>
    <description>&lt;P&gt;Since you use nodupkey in both sorts, it will be a 1:1 merge, and using v003 as third by variable in the merge is unnecessary.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Mar 2020 19:06:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-03-02T19:06:51Z</dc:date>
    <item>
      <title>one to many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/one-to-many-merge/m-p/628874#M20684</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-subject"&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;I am trying to merge 2 datasets using a by for the variables, but I am not sure if the method that I am using is the best method to perform One-to-many merge. I only want unique observations in the final dataset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;For example, I have 2 data sets, one called mother and other called children. So, one&amp;nbsp;mother may have more than one child.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;I started using :&lt;/P&gt;&lt;P&gt;PROC SORT DATA=mother nodupkey out=mother1;&lt;BR /&gt;BY v001 v002 ;&lt;BR /&gt;RUN;&lt;BR /&gt;proc sort data=children nodupkey out=children2;&lt;BR /&gt;by v001 v002 ;&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp;Then I used this method :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;data women1children3;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;merge mother1 (in=ina) children2 (in=inb);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by v001 v002 v003;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if ina=inb;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this method correct&amp;nbsp; for merging one to many, or should I use this one instead: (Defining the file with duplicates as a master)&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;merge&lt;/SPAN&gt; master &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;in1&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; other &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; in1 &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   in1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Mar 2020 18:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/one-to-many-merge/m-p/628874#M20684</guid>
      <dc:creator>xoxozav_1</dc:creator>
      <dc:date>2020-03-02T18:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: one to many merge</title>
      <link>https://communities.sas.com/t5/New-SAS-User/one-to-many-merge/m-p/628884#M20685</link>
      <description>&lt;P&gt;Since you use nodupkey in both sorts, it will be a 1:1 merge, and using v003 as third by variable in the merge is unnecessary.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 19:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/one-to-many-merge/m-p/628884#M20685</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-02T19:06:51Z</dc:date>
    </item>
  </channel>
</rss>

