<?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: compare row values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614312#M76890</link>
    <description>please ignore the output order&lt;BR /&gt;&lt;BR /&gt;just i want compare the column2 value with the column1 values&lt;BR /&gt;&lt;BR /&gt;if column2 value is available in column1 values then column3 have to be prepare with the column2 value of the column 1 value&lt;BR /&gt;&lt;BR /&gt;like&lt;BR /&gt;A B&lt;BR /&gt;1 2&lt;BR /&gt;2 4&lt;BR /&gt;4 7&lt;BR /&gt;&lt;BR /&gt;in the above example i want compare B value 2&lt;BR /&gt;in the column A&lt;BR /&gt;value 2 is available in the column A&lt;BR /&gt;so then i want create column3 like C&lt;BR /&gt;so ouput would be&lt;BR /&gt;A B C&lt;BR /&gt;1 2 4&lt;BR /&gt;after completion of all columnB values comparition&lt;BR /&gt;&lt;BR /&gt;again i want compare columnC values with columnA&lt;BR /&gt;&lt;BR /&gt;and create columnD&lt;BR /&gt;&lt;BR /&gt;and soo on until end&lt;BR /&gt;</description>
    <pubDate>Sun, 29 Dec 2019 19:41:59 GMT</pubDate>
    <dc:creator>sai_kumar</dc:creator>
    <dc:date>2019-12-29T19:41:59Z</dc:date>
    <item>
      <title>compare row values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614309#M76888</link>
      <description>hi experties&lt;BR /&gt;i struck at a point how to compare two different row values&lt;BR /&gt;for example&lt;BR /&gt;input is like below&lt;BR /&gt;&lt;BR /&gt;A B&lt;BR /&gt;&lt;BR /&gt;1 2&lt;BR /&gt;&lt;BR /&gt;2 3&lt;BR /&gt;&lt;BR /&gt;3 4&lt;BR /&gt;&lt;BR /&gt;5 6&lt;BR /&gt;&lt;BR /&gt;6 7&lt;BR /&gt;&lt;BR /&gt;4 5&lt;BR /&gt;&lt;BR /&gt;7 .&lt;BR /&gt;&lt;BR /&gt;then after modification, I want to see&lt;BR /&gt;&lt;BR /&gt;A B C D E F G&lt;BR /&gt;1 2 3 4 5 6 7&lt;BR /&gt;2 3 4 5 6 7&lt;BR /&gt;3 4 5 6 7&lt;BR /&gt;5 6 7&lt;BR /&gt;6 7&lt;BR /&gt;7 .&lt;BR /&gt;4 5 6 7&lt;BR /&gt;please help me in this situation how can i write code</description>
      <pubDate>Sun, 29 Dec 2019 18:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614309#M76888</guid>
      <dc:creator>sai_kumar</dc:creator>
      <dc:date>2019-12-29T18:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: compare row values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614311#M76889</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305055"&gt;@sai_kumar&lt;/a&gt;&amp;nbsp; Welcome to SAS communities. Can you plz explain at point you are stuck and also how you want to compare across rows?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd assume the output order to be the same as input order like&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;4 5 6 7&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;7 .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;rather than&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;7 .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4 5 6 7&lt;/SPAN&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 19:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614311#M76889</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-29T19:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: compare row values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614312#M76890</link>
      <description>please ignore the output order&lt;BR /&gt;&lt;BR /&gt;just i want compare the column2 value with the column1 values&lt;BR /&gt;&lt;BR /&gt;if column2 value is available in column1 values then column3 have to be prepare with the column2 value of the column 1 value&lt;BR /&gt;&lt;BR /&gt;like&lt;BR /&gt;A B&lt;BR /&gt;1 2&lt;BR /&gt;2 4&lt;BR /&gt;4 7&lt;BR /&gt;&lt;BR /&gt;in the above example i want compare B value 2&lt;BR /&gt;in the column A&lt;BR /&gt;value 2 is available in the column A&lt;BR /&gt;so then i want create column3 like C&lt;BR /&gt;so ouput would be&lt;BR /&gt;A B C&lt;BR /&gt;1 2 4&lt;BR /&gt;after completion of all columnB values comparition&lt;BR /&gt;&lt;BR /&gt;again i want compare columnC values with columnA&lt;BR /&gt;&lt;BR /&gt;and create columnD&lt;BR /&gt;&lt;BR /&gt;and soo on until end&lt;BR /&gt;</description>
      <pubDate>Sun, 29 Dec 2019 19:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614312#M76890</guid>
      <dc:creator>sai_kumar</dc:creator>
      <dc:date>2019-12-29T19:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: compare row values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614315#M76891</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305055"&gt;@sai_kumar&lt;/a&gt;&amp;nbsp; Pardon me as I wrote the below code before I saw your response to my previous post. It seems to be the below logic should be close to your requirement&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;
cards;
1 2
2 3
3 4
5 6
6 7
4 5
7 .
;

data want;
set have;
array t(6);
 if _n_=1 then do;
 if 0 then set have(rename=(b=_b));
   dcl hash H (dataset:'have(rename=(b=_b))') ;
   h.definekey  ("a") ;
   h.definedata ("_b") ;
   h.definedone () ;
end;
k=b;
do until(_b=.);
 rc=h.find(key:k);
 n=sum(n,1);
 t(n)=_b;
 k=_b;
end;
drop k _b rc n;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 Dec 2019 20:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614315#M76891</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-29T20:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: compare row values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614374#M76894</link>
      <description>&lt;P&gt;It is called SEARCHING TREE problem .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input _start $ _end $;
cards;
1 2
2 3
3 4
5 6
6 7
4 5
7 .
;
run;
 
data want(keep=path);
if _n_ eq 1 then do;
length path _path  $ 800 ;
if 0 then set have;
declare hash ha(hashexp:20,dataset:'have(where=(_start is not missing and _end is not missing))',multidata:'y');
ha.definekey('_start');
ha.definedata('_end');
ha.definedone();

declare hash pa(ordered:'y');
declare hiter hi_path('pa');
pa.definekey('n');
pa.definedata('n','path');
pa.definedone();

end;


set have;
count=1;n=1;_n=1;
path=catx('|',_start,_end);
   
pa.add();
do while(hi_path.next()=0);
 if n ne 1 then pa.remove(key:_n);_n=n;
 _path=path;   
 _start=scan(path,-1,'|');
 rc=ha.find();   if rc ne 0 then output; 
 do while(rc=0);
  if not findw(path,strip(_end),'|') then do;
   if length(path)+length(_end)+1 gt lengthc(path) then do;
    putlog 'ERROR: The length of path and _path are set too short';
    stop;
   end;
   
   count+1;n=count;
   path=catx('|',path,_end);
   pa.add();
   path=_path;
 end;   else output; /* It is a circle.*/
  rc=ha.find_next();
end;
end;
pa.clear();

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Dec 2019 12:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/compare-row-values/m-p/614374#M76894</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-12-30T12:00:00Z</dc:date>
    </item>
  </channel>
</rss>

