<?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 extract observations have same value from different rows in two columns in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/347968#M10334</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should I do if I want to extract all the observations&amp;nbsp;have same value but may in different two rows in two columns. For example:&lt;/P&gt;&lt;P&gt;Col_1 &amp;nbsp; &amp;nbsp; &amp;nbsp;Col_2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;The red color records are observations I want to extract. I am using SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 01:16:38 GMT</pubDate>
    <dc:creator>echoli</dc:creator>
    <dc:date>2017-04-07T01:16:38Z</dc:date>
    <item>
      <title>extract observations have same value from different rows in two columns</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/347968#M10334</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should I do if I want to extract all the observations&amp;nbsp;have same value but may in different two rows in two columns. For example:&lt;/P&gt;&lt;P&gt;Col_1 &amp;nbsp; &amp;nbsp; &amp;nbsp;Col_2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;The red color records are observations I want to extract. I am using SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 01:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/347968#M10334</guid>
      <dc:creator>echoli</dc:creator>
      <dc:date>2017-04-07T01:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: extract observations have same value from different rows in two columns</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/347975#M10335</link>
      <description>&lt;P&gt;No promises (in fact, not even tested), but this might work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select col_1, col_2 from have&lt;/P&gt;
&lt;P&gt;where col_1 in (select distinct col_2 from have)&lt;/P&gt;
&lt;P&gt;or col_2 in (select distinct col_1 from have);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 03:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/347975#M10335</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-07T03:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: extract observations have same value from different rows in two columns</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/348076#M10338</link>
      <description>&lt;PRE&gt;
data have;
input Col_1      Col_2;
cards;
1              1
2              2
3              3
4              5
5              6
6              7
7              9
8              10
;
run;

data want;
 if _n_=1 then do;
  if 0 then set have;
  declare hash h1(dataset:'have');
  h1.definekey(key:'col_1');
  h1.definedone();
  
  declare hash h2(dataset:'have');
  h2.definekey(key:'col_2');
  h2.definedone();
 end;
set have;
if h1.check(key:col_2)=0 or h2.check(key:col_1)=0;
run;

&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 13:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/extract-observations-have-same-value-from-different-rows-in-two/m-p/348076#M10338</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-07T13:21:59Z</dc:date>
    </item>
  </channel>
</rss>

