<?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: How to select non duplicate values? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257477#M49439</link>
    <description>&lt;P&gt;PROC SORT -&amp;gt; UNIQUEOUT option&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2016 22:36:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-03-17T22:36:00Z</dc:date>
    <item>
      <title>How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257473#M49438</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a file with customerid, code1 and code2 varialbes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Input file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Customerid Code1 Code2&lt;BR /&gt;10001 101 201&lt;BR /&gt;10002 101 201&lt;BR /&gt;10002 101 301&lt;BR /&gt;10002 102 202&lt;BR /&gt;10003 101 201&lt;BR /&gt;10003 101 301&lt;BR /&gt;10003 102 201&lt;BR /&gt;10003 102 301&lt;BR /&gt;10004 101 201&lt;BR /&gt;10004 101 201&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Desired Output file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10001 101 201&lt;BR /&gt;10002 101 201&lt;BR /&gt;10002 101 301&lt;BR /&gt;10002 102 202&lt;BR /&gt;10003 101 201&lt;BR /&gt;10003 102 301&lt;BR /&gt;10004 101 201&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please let me know how can get the desired output file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 22:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257473#M49438</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-03-17T22:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257477#M49439</link>
      <description>&lt;P&gt;PROC SORT -&amp;gt; UNIQUEOUT option&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 22:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257477#M49439</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-17T22:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257478#M49440</link>
      <description>&lt;P&gt;You don't have any patterns here that are consistent from one set of observations to the next. &amp;nbsp;Either fix your example, or explain what the rules are that make an observation a "duplicate".&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 22:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257478#M49440</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-17T22:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257479#M49441</link>
      <description>&lt;P&gt;You need to provide some rules.&lt;/P&gt;
&lt;P&gt;Why for customerid 10002 do you keep both of the code2 when the code1 is 101 but for customerid 10003 you keep the code2 value of 303 but not 201 when code1 is 102?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If those are types and both of the 10003 should have been kept it might be as simple as;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data= have out=want nodupkey;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by customerid code1 code2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Though the values of any other variables in the output dataset&amp;nbsp;could be problematic as to which record gets selected.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 22:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257479#M49441</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-17T22:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257480#M49442</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apologies for not being clear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of 10002, I only want to keep&amp;nbsp;code2 when code2 values are different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10002 101 201&lt;BR /&gt;10002 101 301&lt;BR /&gt;10002 102 202&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of 10003, I only want to keep one row for code1 and code2 combo, because there is duplicate values in code1 and code 2. So I only want to keep one combination of code1/code2 which could be either (101/201 and 102/301) or (101/301 and 102/201).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;10003 101 201&lt;BR /&gt;10003 101 301&lt;BR /&gt;10003 102 201&lt;BR /&gt;10003 102 301&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 23:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257480#M49442</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-03-17T23:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257489#M49446</link>
      <description>&lt;P&gt;Yeah. Use proc sort . If your data arranged like what you showed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Customerid Code1 Code2;
cards;
10001 101 201
10002 101 201
10002 101 301
10002 102 202
10003 101 201
10003 101 301
10003 102 201
10003 102 301
10004 101 201
10004 101 201
;
run;
proc sort data=have out=want nodupkey;
 by Customerid Code2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Mar 2016 01:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257489#M49446</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-18T01:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257712#M49511</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for the below output:&lt;/P&gt;
&lt;P&gt;10001 101 201&lt;/P&gt;
&lt;P&gt;10002 101 201&lt;/P&gt;
&lt;P&gt;10002 101 301&lt;/P&gt;
&lt;P&gt;10002 102 202&lt;/P&gt;
&lt;P&gt;10003 101&amp;nbsp;201&lt;/P&gt;
&lt;P&gt;10003 102 301&lt;/P&gt;
&lt;P&gt;10004 101 201&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 22:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257712#M49511</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-03-18T22:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257743#M49529</link>
      <description>&lt;P&gt;I can't follow what you are saying . It seems it was very difficult problem.&lt;/P&gt;
&lt;P&gt;You need more words to get your question more clear.&lt;/P&gt;
&lt;P&gt;Assuming I understood what you mean.&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;PRE&gt;data x;&lt;BR /&gt;input Customerid Code1 Code2;&lt;BR /&gt;cards;&lt;BR /&gt;10001 101 201&lt;BR /&gt;10002 101 201&lt;BR /&gt;10002 101 301&lt;BR /&gt;10002 102 202&lt;BR /&gt;10003 101 201&lt;BR /&gt;10003 101 301&lt;BR /&gt;10003 102 201&lt;BR /&gt;10003 102 301&lt;BR /&gt;10004 101 201&lt;BR /&gt;10004 101 201&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=x out=have nodupkey;&lt;BR /&gt; by Customerid Code1 Code2;&lt;BR /&gt;run;&lt;BR /&gt;data want;&lt;BR /&gt;if _n_ eq 1 then do;&lt;BR /&gt; if 0 then set have;&lt;BR /&gt; declare hash h(dataset:'have',multidata &amp;amp;colon; 'y');&lt;BR /&gt; h.definekey('Customerid','Code2');&lt;BR /&gt; h.definedata('Customerid','Code1','Code2');&lt;BR /&gt; h.definedone();&lt;BR /&gt;&lt;BR /&gt; declare hash c();&lt;BR /&gt; c.definekey('Customerid','Code2');&lt;BR /&gt; c.definedone();&lt;BR /&gt;&lt;BR /&gt; declare hash cc();&lt;BR /&gt; cc.definekey('Customerid','Code1');&lt;BR /&gt; cc.definedone();&lt;BR /&gt;end;&lt;BR /&gt; set have;&lt;BR /&gt;if c.check() ne 0 then do;&lt;BR /&gt;&lt;BR /&gt; _Code1=Code1;&lt;BR /&gt; rc=h.find(); &lt;BR /&gt; do while(rc=0);&lt;BR /&gt; if _Code1=Code1 then do;c.add();h.removedup();leave;end;&lt;BR /&gt; rc=h.find_next();&lt;BR /&gt; end;&lt;BR /&gt;&lt;BR /&gt; if h.check() ne 0 then output; &lt;BR /&gt; else do;&lt;BR /&gt; if cc.check() ne 0 then do;cc.add();output;end;&lt;BR /&gt; else do;h.find();output;end;&lt;BR /&gt; end;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;drop rc _Code1 ;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Mar 2016 09:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257743#M49529</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-19T09:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257808#M49547</link>
      <description>&lt;P&gt;Thank you! Apologies for not being clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran your code but it did not run successfully. I got the below error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference COLON not resolved.&lt;BR /&gt;ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.&lt;BR /&gt;ERROR 79-322: Expecting a ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please advise?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 02:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257808#M49547</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-03-20T02:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257810#M49549</link>
      <description>&lt;P&gt;Here.&lt;/P&gt;
&lt;PRE&gt; declare hash h(dataset:'have',multidata &amp;amp;colon; 'y');&lt;/PRE&gt;
&lt;P&gt;--&amp;gt;&lt;/P&gt;
&lt;P&gt;declare hash h(dataset:'have',multidata &amp;nbsp;: &amp;nbsp;'y');&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apparently . This forum transform : into colon.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 02:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257810#M49549</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-20T02:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to select non duplicate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257814#M49552</link>
      <description>&lt;P&gt;Thanks a lot!!&lt;/P&gt;
&lt;P&gt;Aprreciate your help!&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 02:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-non-duplicate-values/m-p/257814#M49552</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-03-20T02:55:14Z</dc:date>
    </item>
  </channel>
</rss>

