<?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: Active duplicate records in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38796#M9993</link>
    <description>My code is below:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=combine_mbr            &lt;BR /&gt;
          out=combine_mbr_SORT;      &lt;BR /&gt;
   by emp_no actv_dt; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
 data mbr_error_undup  ;  &lt;BR /&gt;
&lt;BR /&gt;
   set combine_hics;                                   &lt;BR /&gt;
   by emp_no actv_dt; &lt;BR /&gt;
          &lt;BR /&gt;
   if emp_no ne ' ' &lt;BR /&gt;
      then do;&lt;BR /&gt;
           if first.emp_no ne last.emp_no &lt;BR /&gt;
              then Multi_mbrs='Y';&lt;BR /&gt;
           end;&lt;BR /&gt;
&lt;BR /&gt;
   if last.emp_no       then output;   &lt;BR /&gt;
&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 23 Nov 2010 21:06:34 GMT</pubDate>
    <dc:creator>ren2010</dc:creator>
    <dc:date>2010-11-23T21:06:34Z</dc:date>
    <item>
      <title>Active duplicate records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38793#M9990</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am facing a problem,where I have an employee file;this file is a combination of employee data from different employers.So the chances are that an employee number can be shared between multiple employers.I am trying to set a flag for those employee numbers who are only actively working in the company. &lt;BR /&gt;
&lt;BR /&gt;
I did the following:&lt;BR /&gt;
sorted the file on emp_no and active_dt field.&lt;BR /&gt;
&lt;BR /&gt;
Then if first.emp_no ne last.emp_no(only for employees whose active_dt &amp;gt;= today()))  then set the multi_emp to "Y".&lt;BR /&gt;
&lt;BR /&gt;
But I am facing the following issue is like this:&lt;BR /&gt;
for eg:&lt;BR /&gt;
the emp_no 11111 is active in company ABC&lt;BR /&gt;
and emp_no 1111 is non-active in company ZZZ.&lt;BR /&gt;
&lt;BR /&gt;
emp_NO:11111 active_dt:12/31/2099 company name:xxxx&lt;BR /&gt;
emp_NO:11111active_dt: 12/31/2001 company name:vvvvv&lt;BR /&gt;
&lt;BR /&gt;
as per the above logic these records are getting flagged as multi_emp = 'Y'.&lt;BR /&gt;
&lt;BR /&gt;
I only want employees who are active and share same emp_nos;&lt;BR /&gt;
like the following:&lt;BR /&gt;
&lt;BR /&gt;
emp_NO:22222  active_dt:12/31/2099 company name:xxxx&lt;BR /&gt;
emp_NO:22222 active_dt: 12/31/2020 company name:vvvvv&lt;BR /&gt;
emp_NO:22222 active_dt:12/31/2099 company name:KKKK&lt;BR /&gt;
&lt;BR /&gt;
Please share your thoughts.&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Tue, 23 Nov 2010 18:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38793#M9990</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-11-23T18:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Active duplicate records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38794#M9991</link>
      <description>Hello Ren2010,&lt;BR /&gt;
&lt;BR /&gt;
If I've understood you correctly it is necessary to add a company name to your sorting sequence, i.e. company_name emp_no active_dt.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 23 Nov 2010 19:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38794#M9991</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-23T19:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Active duplicate records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38795#M9992</link>
      <description>Suggest you share whatever code piece you may have tried that is not working?&lt;BR /&gt;
&lt;BR /&gt;
And, suggesting also that you try adding this code line so you can tell when you have FIRST.&lt;BREAK_VARIABLE&gt; and/or LAST.&lt;BREAK_VARIABLE&gt; (where "nn" can be unique and you can insert multiples at various DATA step locations to see effect):&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;DIAG-nn&amp;gt;' / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For your interest, I believe that BY GROUP processing, while having the proper sorted file and also having the BY statement variable optimized, then you can identify unique conditions / characteristics for your data and set a flag accordingly.&lt;BR /&gt;
&lt;BR /&gt;
It will work-out as long as you find a suitable combination and sequence for your BY variables, then test those conditions while using the PUTLOG example.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
by group processing site:sas.com&lt;/BREAK_VARIABLE&gt;&lt;/BREAK_VARIABLE&gt;</description>
      <pubDate>Tue, 23 Nov 2010 19:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38795#M9992</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-23T19:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Active duplicate records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38796#M9993</link>
      <description>My code is below:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=combine_mbr            &lt;BR /&gt;
          out=combine_mbr_SORT;      &lt;BR /&gt;
   by emp_no actv_dt; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
 data mbr_error_undup  ;  &lt;BR /&gt;
&lt;BR /&gt;
   set combine_hics;                                   &lt;BR /&gt;
   by emp_no actv_dt; &lt;BR /&gt;
          &lt;BR /&gt;
   if emp_no ne ' ' &lt;BR /&gt;
      then do;&lt;BR /&gt;
           if first.emp_no ne last.emp_no &lt;BR /&gt;
              then Multi_mbrs='Y';&lt;BR /&gt;
           end;&lt;BR /&gt;
&lt;BR /&gt;
   if last.emp_no       then output;   &lt;BR /&gt;
&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 23 Nov 2010 21:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38796#M9993</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-11-23T21:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Active duplicate records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38797#M9994</link>
      <description>Your FIRST. and LAST. processing logic is flawed (you may be thinking of LAG instead?) -- the condition is either a 1 or a 0, which leads back to the idea of adding the PUTLOG statements for self-diagnosis.  Also, suggest reading more about BY GROUP PROCESSING in the SAS support website references and SAS-hosted DOC.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 23 Nov 2010 21:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Active-duplicate-records/m-p/38797#M9994</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-23T21:09:01Z</dc:date>
    </item>
  </channel>
</rss>

