<?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: Delete duplicate rows if two variables are not identical in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368693#M87940</link>
    <description>&lt;PRE&gt;
To be honest. I don't understand your question.

data have;
input (Person Sport1 Sport2) ($);
cards;
A Soccer Soccer 
A Soccer Table Tennis 
A Soccer Rugby 
B Footy Footy 
C Baseball Baseball 
D Tennis Badmington 
D Tennis Tennis 
;
run;
proc sql;
select *
 from have
  group by person
   having sum(sport1=sport2) ne count(*) and  sum(sport1=sport2) ne 0;
quit;

&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Jun 2017 12:40:03 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-06-20T12:40:03Z</dc:date>
    <item>
      <title>Delete duplicate rows if two variables are not identical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368583#M87920</link>
      <description>&lt;P&gt;I want to keep only the duplicates where there is an identical match betwwen sport1 and sport2. So in the following table I only want to keep Person A where sport1 and Sport2 are both soccer and Person D where Sport1 and Sport2 are both Tennis&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Person&lt;/TD&gt;&lt;TD&gt;Sport1&lt;/TD&gt;&lt;TD&gt;Sport2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Soccer&lt;/TD&gt;&lt;TD&gt;Soccer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Soccer&lt;/TD&gt;&lt;TD&gt;Table Tennis&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Soccer&lt;/TD&gt;&lt;TD&gt;Rugby&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Footy&lt;/TD&gt;&lt;TD&gt;Footy&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;Baseball&lt;/TD&gt;&lt;TD&gt;Baseball&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;Tennis&lt;/TD&gt;&lt;TD&gt;Badmington&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;Tennis&lt;/TD&gt;&lt;TD&gt;Tennis&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 20 Jun 2017 06:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368583#M87920</guid>
      <dc:creator>BenBrady</dc:creator>
      <dc:date>2017-06-20T06:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate rows if two variables are not identical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368588#M87922</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if sport1 = sport2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is called a subsetting if.&lt;/P&gt;
&lt;P&gt;You can do it in a where condition, if you want only one entry per person:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have (
    where=(sport1 = sport2)
  )
  out=want (keep=person)
  nodupkey
;
by person;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Jun 2017 06:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368588#M87922</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-20T06:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete duplicate rows if two variables are not identical</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368693#M87940</link>
      <description>&lt;PRE&gt;
To be honest. I don't understand your question.

data have;
input (Person Sport1 Sport2) ($);
cards;
A Soccer Soccer 
A Soccer Table Tennis 
A Soccer Rugby 
B Footy Footy 
C Baseball Baseball 
D Tennis Badmington 
D Tennis Tennis 
;
run;
proc sql;
select *
 from have
  group by person
   having sum(sport1=sport2) ne count(*) and  sum(sport1=sport2) ne 0;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Jun 2017 12:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-duplicate-rows-if-two-variables-are-not-identical/m-p/368693#M87940</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-20T12:40:03Z</dc:date>
    </item>
  </channel>
</rss>

