<?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 Keep Full Sample of One File After Merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355034#M83140</link>
    <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to keep the full sample of one file after merge. However, I tried many times but still got higher number. Could anyone give me some suggestions? Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA ANALYTIC (replace=yes);&lt;/P&gt;&lt;P&gt;MERGE ADM_forHYBRID (in=x) &amp;nbsp;MFILE (in=y);&lt;BR /&gt;BY STATEFIP PROVIDER ;&lt;BR /&gt;if x=1 then output;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log shows that the ADM file has&amp;nbsp;20804087 observations and the MFILE has&amp;nbsp;177125 observations. However, after merge, the file has&amp;nbsp;20804107 observations. I want the final file to be&amp;nbsp;&lt;SPAN&gt;20804087 observations but I cannot get that number. Could anyone help me solve the issue?&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 19:25:58 GMT</pubDate>
    <dc:creator>DanC</dc:creator>
    <dc:date>2017-05-01T19:25:58Z</dc:date>
    <item>
      <title>Keep Full Sample of One File After Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355034#M83140</link>
      <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to keep the full sample of one file after merge. However, I tried many times but still got higher number. Could anyone give me some suggestions? Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA ANALYTIC (replace=yes);&lt;/P&gt;&lt;P&gt;MERGE ADM_forHYBRID (in=x) &amp;nbsp;MFILE (in=y);&lt;BR /&gt;BY STATEFIP PROVIDER ;&lt;BR /&gt;if x=1 then output;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log shows that the ADM file has&amp;nbsp;20804087 observations and the MFILE has&amp;nbsp;177125 observations. However, after merge, the file has&amp;nbsp;20804107 observations. I want the final file to be&amp;nbsp;&lt;SPAN&gt;20804087 observations but I cannot get that number. Could anyone help me solve the issue?&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 19:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355034#M83140</guid>
      <dc:creator>DanC</dc:creator>
      <dc:date>2017-05-01T19:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Full Sample of One File After Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355039#M83141</link>
      <description>&lt;P&gt;This is a sign that MFILE occasionally contains more than one observation for a combination of STATEFIP / PROVIDER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are ways to deal with this, but first you have to decide ... what should happen when there is a one-to-many match?&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 19:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355039#M83141</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-01T19:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Full Sample of One File After Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355250#M83204</link>
      <description>&lt;P&gt;Thank you Astounding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I delete duplicate observations in the MFILE by STATEFIP and PROVIDER. But still get the same number of observations after merge the two datasets. Do you have any suggestion?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 14:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355250#M83204</guid>
      <dc:creator>DanC</dc:creator>
      <dc:date>2017-05-02T14:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Full Sample of One File After Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355294#M83215</link>
      <description>&lt;P&gt;The issue will remain the same.&amp;nbsp; Perhaps there are observations in MFILE with the same STATEFIP + PROVIDER, but having a different value for some other variable.&amp;nbsp; You could definitely eliminate duplicates with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=mfile out=deduped nodupkey;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by statefip provider;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While that gives you the proper number of observations, it will not tell you which observations were selected and which were deleted.&amp;nbsp; You might just want to examine where the duplicates come from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data small_subset;&lt;/P&gt;
&lt;P&gt;set mfile;&lt;/P&gt;
&lt;P&gt;by statefip provider;&lt;/P&gt;
&lt;P&gt;if first.provider=0 or last.provider=0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 15:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Full-Sample-of-One-File-After-Merge/m-p/355294#M83215</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-02T15:59:20Z</dc:date>
    </item>
  </channel>
</rss>

