<?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: Looking for Like Values in Array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/764023#M241965</link>
    <description>&lt;P&gt;the "Colon Modifier"&amp;nbsp; for the string comparisons&amp;nbsp;in SAS is also known as "Bounded String Compare".&amp;nbsp; Just to articulate the concepts so its easier search this forum.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 20:52:11 GMT</pubDate>
    <dc:creator>PhilC</dc:creator>
    <dc:date>2021-08-25T20:52:11Z</dc:date>
    <item>
      <title>Looking for Like Values in Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763300#M241722</link>
      <description>&lt;P&gt;I'm trying to use a "Like" operator on values within an array. Below are the data sets I have and want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

input code1 $ code2 $ code3 $;
datalines;
F334 F456 F213
F321 Y758 I893
F333 F231 F792
G567 F333 F334
F032 U234 F335
T430 R456 E345
;
run;

data want;
input code1 $ code2 $ code3 $ flag;
datalines;
F334 F456 F213 1
F321 Y758 I893 0
F333 F231 F792 1
G567 F333 F334 1
F032 U234 F335 1
T430 R456 E345 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Below is my attempt and I believe gets at what I'm trying to do. Is there any way to do a like or wildcard operator on array operations like this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   array d code1-code3;
   flag=0;
   do i=1 to dim(d);
      if d[i] like ( "F33%") then do;
         flag=1;
         leave;
      end;
   end;
   drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Aug 2021 17:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763300#M241722</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2021-08-23T17:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Like Values in Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763303#M241723</link>
      <description>&lt;P&gt;I think that you may want to provide&amp;nbsp; a bit of detail of exactly which you are counting "within an array".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to compare if two strings begin with the same characters you can use the =:&amp;nbsp; &amp;lt;look close there is a colon after the equal sign&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array d code1-code3;
   flag=0;
   do i=1 to dim(d);
      if d[i] =:  "F33" then do;
         flag=1;
         leave;
      end;
   end;
   drop i;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Aug 2021 17:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763303#M241723</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-23T17:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Like Values in Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763306#M241725</link>
      <description>&lt;P&gt;I'm not well-versed on this technique, but some people in my department use the colon modifier within an array to do things like this. Someone correct me if this isn't a good method.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_2 (drop = i);
	set have;
	array f33_find [*] code:;
	flag = 0;
	do i = 1 to dim(f33_find);
		if f33_find[i] in: ("F33") then flag = 1;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;code1 code2 code3 flag 
F334 F456 F213 1 
F321 Y758 I893 0 
F333 F231 F792 1 
G567 F333 F334 1 
F032 U234 F335 1 
T430 R456 E345 0 

&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://www.pharmasug.org/proceedings/2012/TA/PharmaSUG-2012-TA05.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p073-26.pdf&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 17:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763306#M241725</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-23T17:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Like Values in Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763390#M241759</link>
      <description>&lt;P&gt;Below another coding option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input code1 $ code2 $ code3 $ flag;
  flag_2= ( prxmatch('/\bF33/oi',catx(',',code1,code2,code3))&amp;gt;0 );
  flag_3= ( find(','||catx(',',code1,code2,code3),',F33','i')&amp;gt;0 );
  datalines;
F334 F456 F213 1
F321 Y758 I893 0
F333 F231 F792 1
G567 F333 F334 1
F032 U234 F335 1
T430 R456 E345 0
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Aug 2021 23:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/763390#M241759</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-08-23T23:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Like Values in Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/764023#M241965</link>
      <description>&lt;P&gt;the "Colon Modifier"&amp;nbsp; for the string comparisons&amp;nbsp;in SAS is also known as "Bounded String Compare".&amp;nbsp; Just to articulate the concepts so its easier search this forum.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 20:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-Like-Values-in-Array/m-p/764023#M241965</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-08-25T20:52:11Z</dc:date>
    </item>
  </channel>
</rss>

