<?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: Keep only ID duplicates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854578#M337744</link>
    <description>After running your suggested code, I ended up with a list of observations that only shows the ID column, and none of the IDs are duplicate.</description>
    <pubDate>Thu, 19 Jan 2023 13:59:20 GMT</pubDate>
    <dc:creator>Satori</dc:creator>
    <dc:date>2023-01-19T13:59:20Z</dc:date>
    <item>
      <title>Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854569#M337738</link>
      <description>&lt;P&gt;I have a dataset like this (below).&amp;nbsp;The variable code takes only two values ('C2', 'U2')&lt;/P&gt;&lt;P&gt;The ID variable is not unique. There can be an ID with only code U2, only code C2 and with both codes. I want to keep only the last one of these, meaning I want to keep the observations with the same ID and different codes, and drop all IDs that have only one code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;code&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE0000037163&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; U2&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE0000037282&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; U2&lt;BR /&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE0000037693&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; U2&lt;BR /&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE0000037738&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; U2&lt;BR /&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE0000037738 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854569#M337738</guid>
      <dc:creator>Satori</dc:creator>
      <dc:date>2023-01-19T13:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854570#M337739</link>
      <description>&lt;P&gt;Please provide data that illustrates the problem. Right now, there is no ID which has both U2 and C2.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854570#M337739</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-19T13:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854572#M337740</link>
      <description>I have a dataset like this (below). The variable code takes only two values ('C2', 'U2')&lt;BR /&gt;&lt;BR /&gt;The ID variable is not unique. There can be an ID with only code U2, only code C2 and with both codes. I want to keep only the last one of these, meaning I want to keep the observations with the same ID and different codes, and drop all IDs that have only one code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Obs ID code&lt;BR /&gt;&lt;BR /&gt;1 AE0000037163 U2&lt;BR /&gt;2 AE0000037282 U2&lt;BR /&gt;3 AE0000037693 U2&lt;BR /&gt;4 AE0000037738 U2&lt;BR /&gt;5 AE0000037738 C2&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854572#M337740</guid>
      <dc:creator>Satori</dc:creator>
      <dc:date>2023-01-19T13:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854575#M337742</link>
      <description>&lt;P&gt;From now on, please provide data as &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;WORKING&lt;/STRONG&gt; &lt;/FONT&gt;data step code, as I have shown below in creating data set named HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Obs ID $12. code $;
cards;
1 AE0000037163 U2
2 AE0000037282 U2
3 AE0000037693 U2
4 AE0000037738 U2
5 AE0000037738 C2
;

proc sql;
    create table want as select id
    from have
    group by id
    having sum(code='U2')&amp;gt;0 and sum(code='C2')&amp;gt;0; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854575#M337742</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-19T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854578#M337744</link>
      <description>After running your suggested code, I ended up with a list of observations that only shows the ID column, and none of the IDs are duplicate.</description>
      <pubDate>Thu, 19 Jan 2023 13:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854578#M337744</guid>
      <dc:creator>Satori</dc:creator>
      <dc:date>2023-01-19T13:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854583#M337745</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173636"&gt;@Satori&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;After running your suggested code, I ended up with a list of observations that only shows the ID column, and none of the IDs are duplicate.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand this. Show us what you see. Show us what you want to see.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 14:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854583#M337745</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-19T14:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only ID duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854585#M337746</link>
      <description>&lt;P&gt;I will assume you want to see the NON-unique ID values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input Obs ID:$12. code $;
   cards;
1 AE0000037163 U2
2 AE0000037282 U2
3 AE0000037693 U2
4 AE0000037738 U2
5 AE0000037738 C2
;
run;
proc print;
proc sort data=have nounikey out=dups uniout=_null_;
   by id;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 219px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79520i7C092DA77218BCD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 14:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-ID-duplicates/m-p/854585#M337746</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2023-01-19T14:12:14Z</dc:date>
    </item>
  </channel>
</rss>

