<?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 data sets and ensuring additional records are not created. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258354#M57347</link>
    <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;I am merging two data sets with the below statement and when I do a few extra records are being created in the new data set. Is there any way I can either prevent this or identify the additional records in the new data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the s0ssrp data set, there are 514,983. In the new s0ssrp1, there are 515,013.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data s0ssrp1 (rename=closed_reason=FtcOutcome);&lt;BR /&gt;merge s0ssrp (in=a) ssrpucms2 (keep=County Docket ReferralDate FtcStatus closed_reason ContractDate);&lt;BR /&gt;if a;&lt;BR /&gt;by County Docket;&lt;BR /&gt;&lt;BR /&gt;if ReferralDate ge start and ReferralDate le stop then do;&lt;BR /&gt;FtcReferred="Y";&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;else FtcReferred="N";&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2016 20:10:46 GMT</pubDate>
    <dc:creator>Paul_NYS</dc:creator>
    <dc:date>2016-03-22T20:10:46Z</dc:date>
    <item>
      <title>Merging two data sets and ensuring additional records are not created.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258354#M57347</link>
      <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;I am merging two data sets with the below statement and when I do a few extra records are being created in the new data set. Is there any way I can either prevent this or identify the additional records in the new data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the s0ssrp data set, there are 514,983. In the new s0ssrp1, there are 515,013.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data s0ssrp1 (rename=closed_reason=FtcOutcome);&lt;BR /&gt;merge s0ssrp (in=a) ssrpucms2 (keep=County Docket ReferralDate FtcStatus closed_reason ContractDate);&lt;BR /&gt;if a;&lt;BR /&gt;by County Docket;&lt;BR /&gt;&lt;BR /&gt;if ReferralDate ge start and ReferralDate le stop then do;&lt;BR /&gt;FtcReferred="Y";&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;else FtcReferred="N";&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 20:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258354#M57347</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2016-03-22T20:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets and ensuring additional records are not created.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258362#M57348</link>
      <description>&lt;P&gt;This would happen if your second data set, ssrpucms2, occasionally contained more than one observation for a combination of COUNTY + DOCKET.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need help in locating where the duplicates are?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 21:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258362#M57348</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-22T21:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets and ensuring additional records are not created.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258364#M57349</link>
      <description>&lt;P&gt;I thought there were a lot of duplicates actually. But if this is the only scenario that would produce more than one record from the original data set, then I will take a look at the file tomorrow morning and check it further. If that is the case then that is an easier scenario than I thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will get back. Thanks Astounding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 21:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258364#M57349</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2016-03-22T21:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets and ensuring additional records are not created.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258367#M57350</link>
      <description>&lt;P&gt;Hi Paul,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find the&amp;nbsp;duplicate combinations of County and Docket in dataset SSRPUCMS2 by submitting the following data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dups;
set ssrpucms2;
by County Docket;
if ~(first.docket &amp;amp; last.docket);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this resulted in more than 60 (=2*(515,013-514,983)) observations, it would seem that also dataset S0SSRP contains such duplicates. In this case the merge step would be questionable and should have created a message&lt;/P&gt;
&lt;PRE&gt;NOTE: MERGE statement has more than one data set with repeats of BY values.&lt;/PRE&gt;
&lt;P&gt;in the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you could replace &lt;FONT face="courier new,courier"&gt;ssrpucms2&lt;/FONT&gt; by &lt;FONT face="courier new,courier"&gt;s0ssrp&lt;/FONT&gt; in&amp;nbsp;the above data step and should be alarmed if the resulting dataset DUPS is not empty.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 21:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258367#M57350</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-22T21:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two data sets and ensuring additional records are not created.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258399#M57353</link>
      <description>&lt;P&gt;If&amp;nbsp;County-Docket is a unique key in&amp;nbsp;s0ssrp, you can choose to use the first or the last matching record from&amp;nbsp;ssrpucms2 in the following way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data s0ssrp1 (rename=closed_reason=FtcOutcome);
merge s0ssrp (in=a) ssrpucms2 (in=b keep=County Docket ReferralDate FtcStatus closed_reason ContractDate);
by County Docket;

/* Use the first record from ssrpucms2 in a County-Docket group */
if a and (not b or first.Docket);

/* Or... */

/* Use the last record from ssrpucms2 in a County-Docket group */
if a and (not b or last.Docket);

if ReferralDate ge start and ReferralDate le stop then FtcReferred="Y";
else FtcReferred="N";

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2016 02:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-two-data-sets-and-ensuring-additional-records-are-not/m-p/258399#M57353</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-23T02:29:11Z</dc:date>
    </item>
  </channel>
</rss>

