<?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: A specific way to define duplicates by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538576#M148277</link>
    <description>&lt;P&gt;yes or just :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by session_id device_name notsorted time notsorted;

   if first.session_id then dup=0;
   if first.time then dup+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Feb 2019 06:50:41 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2019-02-26T06:50:41Z</dc:date>
    <item>
      <title>A specific way to define duplicates by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538572#M148275</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a&amp;nbsp;dataset with duplicates and I'm trying to study duplicated records, the dataset is shaped as of the following, and I'm trying to create a dup variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dup count will be grouped by session_id, device_name and time, and it will have repeated numbers if the defined group are identical within session_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;session_id  device_name    time   dup
    1          desktop       12    1
    1          desktop       12    1
    1          desktop       12    1
    1          tablet        10    2&lt;BR /&gt;    2          tablet        11    1&lt;BR /&gt;    2          tablet        11    1&lt;BR /&gt;    2          mobile        10    2&lt;BR /&gt;    2          desktop       10    3&lt;BR /&gt;    3          desktop       10    1&lt;BR /&gt;    3          desktop       10    1&lt;BR /&gt;  &lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Appreciate for any help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 06:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538572#M148275</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-26T06:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: A specific way to define duplicates by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538574#M148276</link>
      <description>&lt;P&gt;You can do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input session_id device_name $ time;
datalines;
1 desktop 12
1 desktop 12
1 desktop 12
1 tablet 10
2 tablet 11
2 tablet 11
2 mobile 10
2 desktop 10
3 desktop 10
3 desktop 10
;

data want(drop=_:);
   set have;
   by session_id device_name notsorted time notsorted;

   _session_id=lag1(session_id);
   _device_name=lag1(device_name); 
   _time=lag1(time);

   if session_id ne _session_id | device_name ne _device_name | time ne _time then do;
      dup+1;
   end;
   
   if first.session_id then dup=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 06:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538574#M148276</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-02-26T06:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: A specific way to define duplicates by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538576#M148277</link>
      <description>&lt;P&gt;yes or just :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by session_id device_name notsorted time notsorted;

   if first.session_id then dup=0;
   if first.time then dup+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 06:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-specific-way-to-define-duplicates-by-groups/m-p/538576#M148277</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2019-02-26T06:50:41Z</dc:date>
    </item>
  </channel>
</rss>

