<?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 compare values in two columns regardless of the row orders? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251680#M47597</link>
    <description>&lt;P&gt;You may need to&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct a.var1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if the value could be repeated in each column more than one time. Or you will end up by long list.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Feb 2016 23:35:46 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2016-02-22T23:35:46Z</dc:date>
    <item>
      <title>How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251658#M47591</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two columns with the same type character values. I just want to check if there is any duplicate between thease two columns (when I say duplicate, I don't mean duplicate at each row; I mean any repeated value in both columns&amp;nbsp;regardless of the order.) Could you please help with it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 22:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251658#M47591</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-22T22:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251675#M47594</link>
      <description>&lt;P&gt;What do you want the output to be?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 22:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251675#M47594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-22T22:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251678#M47595</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65070"&gt;@almmotamedi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length var1 var2 $10;
input var1 var2;
cards;
blue   red
green  yellow
red    brown
black  green
;

proc sql;
create table dups as
select a.var1
from have a, have b
where a.var1=b.var2;
quit;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;var1

green
red&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 23:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251678#M47595</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-22T23:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251680#M47597</link>
      <description>&lt;P&gt;You may need to&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct a.var1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if the value could be repeated in each column more than one time. Or you will end up by long list.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 23:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251680#M47597</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-22T23:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251692#M47600</link>
      <description>&lt;P&gt;It looks like you need some QUERY tool. MERGE, Hash Table, SQL , IML ,Array ..... all can do that.&lt;/P&gt;
&lt;P&gt;Here is the IML code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length var1 var2 $10;
input var1 var2;
cards;
blue   red
green  yellow
red    brown
black  green
;
run;
proc iml;
use have;
read all var {var1 var2};
close have;
x=var1[loc(element(var1,var2))];
print x;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Feb 2016 01:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251692#M47600</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-23T01:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251709#M47607</link>
      <description>&lt;P&gt;Its simply like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;column1 &amp;nbsp; &amp;nbsp;column2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create the New_column1 as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New_column1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Because, A and D are not repeated/duplicate in the 2nd column.)&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 03:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251709#M47607</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-23T03:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251736#M47616</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65070"&gt;@almmotamedi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the clarification. If you want to create a new dataset (call it WANT) with one variable, New_column1, from the existing dataset (call it HAVE) with the two variables, you could use the EXCEPT operator in&amp;nbsp;PROC SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select column1 as New_column1 from have
except
select column2 from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that, say, "B" should not occur in New_column1 even if it occurred twice in column1, but only once in column2. If, in the latter case, you would like to take into account the "multiplicities", i.e. eliminate only one of the two occurrences of "B", just replace &lt;FONT face="courier new,courier"&gt;except&lt;/FONT&gt; by &lt;FONT face="courier new,courier"&gt;except all&lt;/FONT&gt; in the code above.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 09:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251736#M47616</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-23T09:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare values in two columns regardless of the row orders?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251769#M47626</link>
      <description>Thank you so much</description>
      <pubDate>Tue, 23 Feb 2016 14:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-values-in-two-columns-regardless-of-the-row/m-p/251769#M47626</guid>
      <dc:creator>almmotamedi</dc:creator>
      <dc:date>2016-02-23T14:07:47Z</dc:date>
    </item>
  </channel>
</rss>

