<?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: MERGE statement has more than one data set with repeats of BY values. in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759906#M37016</link>
    <description>&lt;P&gt;A data step MERGE is not the correct tool for handling m:n relationships, it's good for 1:1, 1:n and n:1.&lt;/P&gt;
&lt;P&gt;Depending on your intentions, you should either&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;use SQL and build a cartesian join&lt;/LI&gt;
&lt;LI&gt;deduplicate one or both datasets before doing the MERGE&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Fri, 06 Aug 2021 10:43:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-08-06T10:43:18Z</dc:date>
    <item>
      <title>MERGE statement has more than one data set with repeats of BY values.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759895#M37014</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;How to get rid of this note 'Merge statement' from the log.&amp;nbsp;I understand there are duplicates in the code but any alternate way of doing this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please advise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;845        data wan;
846        merge XM_Pdms_1 (drop=XMDY) XM_Pdms_1 (where=(XMDY ne .));
847        by USUBJID VISITNUM ;
848        run;

NOTE: MERGE statement has more than one data set with repeats of BY values.
NOTE: There were 19662 observations read from the data set WORK.XM_PDMS_1.
NOTE: There were 16950 observations read from the data set WORK.XM_PDMS_1.
      WHERE XMDY not = .;
NOTE: The data set WORK.WAN has 19662 observations and 25 variables.
NOTE: DATA statement used (Total process time):
      real time           0.24 seconds
      cpu time            0.20 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Aug 2021 08:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759895#M37014</guid>
      <dc:creator>bharath86</dc:creator>
      <dc:date>2021-08-06T08:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE statement has more than one data set with repeats of BY values.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759900#M37015</link>
      <description>&lt;P&gt;Before asking about suppressing a note in the log did you look at the resulting data? Is it correct or what you expect?&lt;/P&gt;
&lt;P&gt;Almost 100% of the time that note means that the result is likely not what you want.&lt;/P&gt;
&lt;P&gt;So the question is what should the result look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest making small examples of the two data sets with some duplicates of the by variables and some records not duplicating the by variables, and what the result is intended to be and share all three data sets. Otherwise we do not know what your intent is.The example datasets should include only one or two other variables but the values of those variables need to of sufficient variety to see how they are treated.&lt;/P&gt;
&lt;P&gt;The solution will likely involve Proc SQL and a Join. But there are several different joins and which to use depends on what the expected result looks like.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Aug 2021 09:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759900#M37015</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-06T09:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE statement has more than one data set with repeats of BY values.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759906#M37016</link>
      <description>&lt;P&gt;A data step MERGE is not the correct tool for handling m:n relationships, it's good for 1:1, 1:n and n:1.&lt;/P&gt;
&lt;P&gt;Depending on your intentions, you should either&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;use SQL and build a cartesian join&lt;/LI&gt;
&lt;LI&gt;deduplicate one or both datasets before doing the MERGE&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 06 Aug 2021 10:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/MERGE-statement-has-more-than-one-data-set-with-repeats-of-BY/m-p/759906#M37016</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-06T10:43:18Z</dc:date>
    </item>
  </channel>
</rss>

