<?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: Duplicate values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326874#M72874</link>
    <description>&lt;P&gt;First, sort your data set if it is not already in order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by a b c;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then get the data set you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by a b c;&lt;/P&gt;
&lt;P&gt;if last.c;&lt;/P&gt;
&lt;P&gt;if first.c=0 then d='z';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 22:19:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-01-23T22:19:35Z</dc:date>
    <item>
      <title>Duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326859#M72870</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a dataset with 4 variables and many rows, among the records few rows have duplicate records except one variable (See the attached picture). If any rows that have a, b, c common values and different d value then i want to delete one row and change the value of d to z.&lt;/P&gt;&lt;P&gt;How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13350iEF56CE000A177AEB/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Untitled.png" title="Untitled.png" /&gt;</description>
      <pubDate>Mon, 23 Jan 2017 21:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326859#M72870</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-01-23T21:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326874#M72874</link>
      <description>&lt;P&gt;First, sort your data set if it is not already in order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by a b c;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then get the data set you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by a b c;&lt;/P&gt;
&lt;P&gt;if last.c;&lt;/P&gt;
&lt;P&gt;if first.c=0 then d='z';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 22:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326874#M72874</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-23T22:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326906#M72890</link>
      <description>&lt;P&gt;Here's an SQL version that might do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d $;
datalines;	
1 2 3 x
1 2 2 x
1 2 2 y
2 1 1 x
1 2 4 y
1 2 4 x
;

proc sql;
    CREATE TABLE want AS
    SELECT DISTINCT a, b, c, 
           CASE count(DISTINCT d) WHEN 1 THEN d
                ELSE 'z'
           END AS d
    FROM have
    GROUP BY a, b, c;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm not sure how you'd easily get the final sort order you have in your image, but I think this gets the data right.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 01:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-values/m-p/326906#M72890</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-01-24T01:49:11Z</dc:date>
    </item>
  </channel>
</rss>

