<?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: Using Arrays to check equality of groups of strings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453126#M114461</link>
    <description>&lt;P&gt;Just a little change in the logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
set table;
array check1 a1-a3;
array check2 b1-b3;
match = 0;
do i = 1 to 3;
  if check1{i} = check2{i} then match = 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Apr 2018 10:09:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-04-11T10:09:18Z</dc:date>
    <item>
      <title>Using Arrays to check equality of groups of strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453123#M114458</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By way of example, I have two groups of strings as shown below, a1-a3 and b1-b3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to know if at least one of the strings in a1-a3 is equal to at least one of the strings in b1-b3. Then flag the rows which satisfy this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I imagine this will be done using arrays and a do loop. I realise my attempt in the code below will only work if all a1-a3 are identical to b1-b3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would really appreciate some help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table ;
input a1 $ a2 $ a3 $ b1 $ b2 $ b3 $ match $ ;
cards ;
a b c a b c Yes
a b c a d e Yes 
a b c d e f no 
a b c a b e Yes
; 
run ;

data table ;
set table ;
array check1 a1-a3 ;
array check2 b1-b3 ;
do i=1 to 3 ;
if check1(i)=check2(i) then match =1 ;
else match=0 ;
end ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 09:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453123#M114458</guid>
      <dc:creator>mattteale</dc:creator>
      <dc:date>2018-04-11T09:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arrays to check equality of groups of strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453126#M114461</link>
      <description>&lt;P&gt;Just a little change in the logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
set table;
array check1 a1-a3;
array check2 b1-b3;
match = 0;
do i = 1 to 3;
  if check1{i} = check2{i} then match = 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Apr 2018 10:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453126#M114461</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-11T10:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arrays to check equality of groups of strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453127#M114462</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data table ;
  input a1 $ a2 $ a3 $ b1 $ b2 $ b3 $;
cards ;
a b c a b c
a b c a d e
a b c d e f 
a b c a b e
; 
run;

data want;
  set table;
  array a{3};
  do i=1 to dim(a);
    if whichc(a{i},of b:) then match="yes";
  end;
run;&lt;/PRE&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>Wed, 11 Apr 2018 10:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453127#M114462</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-11T10:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arrays to check equality of groups of strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453128#M114463</link>
      <description>&lt;P&gt;Thank you so much pal&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 10:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Arrays-to-check-equality-of-groups-of-strings/m-p/453128#M114463</guid>
      <dc:creator>mattteale</dc:creator>
      <dc:date>2018-04-11T10:12:33Z</dc:date>
    </item>
  </channel>
</rss>

