<?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: Finding a value in text from a variable that contains a list of values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564474#M158345</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="\b(all|you)\b";  /* will find if word 'all' or 'you' is found the text 'texto' below , text is delimited with | */
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';   /* &amp;lt;= instead of word all , the text can contain the word you*/
if prxmatch(cats("/",ra,"/"),texto) then do;
    bi="wee";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jun 2019 14:29:59 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2019-06-07T14:29:59Z</dc:date>
    <item>
      <title>Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564471#M158344</link>
      <description>&lt;P&gt;Hi Dear All.&lt;BR /&gt;&lt;BR /&gt;I have this working code code :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="all";
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';
if index(texto,(trim(ra)))&amp;gt;0 then do;
bi="wee";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I would like to transorm the re variable to a list , so index could find the string if one of the values of the list 're' is found, here is an example&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="all|you";&amp;nbsp; /* will find if word 'all' or 'you' is found the text 'texto' below&amp;nbsp;, text is delimited with |&amp;nbsp;*/
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello &lt;STRONG&gt;all&lt;/STRONG&gt;, people';&amp;nbsp; &amp;nbsp;/* &amp;lt;= instead of word all , the text can contain the word &lt;STRONG&gt;you&lt;/STRONG&gt;*/
if index(texto,(trim(ra)))&amp;gt;0 then do;
bi="wee";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for your response.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564471#M158344</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-07T14:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564474#M158345</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="\b(all|you)\b";  /* will find if word 'all' or 'you' is found the text 'texto' below , text is delimited with | */
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';   /* &amp;lt;= instead of word all , the text can contain the word you*/
if prxmatch(cats("/",ra,"/"),texto) then do;
    bi="wee";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564474#M158345</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-06-07T14:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564475#M158346</link>
      <description>&lt;P&gt;Thank you for the response, but I would like to find the answer &lt;STRONG&gt;using sas code&lt;/STRONG&gt; and &lt;U&gt;&lt;STRONG&gt;not re&lt;/STRONG&gt;&lt;/U&gt;.&lt;BR /&gt;(* sorry, since i forgot to mention that &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; )&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564475#M158346</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-07T14:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564477#M158347</link>
      <description>&lt;P&gt;prxmatch is sas code but i understand you don't want to use regular expressions (why ?).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a solution without regex. Note that it will match the string "hello young fellow" for instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="all|you"; 
ro="hello";

texto='blablabla hello all, people';

do i=1 to countw(re,'|');
	re2=scan(re,i,'|');
	ra=catx('',ro,re2);

	if index(texto, trim(ra)) then do;
	    bi="wee";
	end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564477#M158347</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-06-07T14:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564572#M158381</link>
      <description>&lt;P&gt;Why not Regular Expressions? They are your best bet for this task.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 20:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564572#M158381</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-06-07T20:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564664#M158409</link>
      <description>&lt;P&gt;Using a array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
re="all|you";  
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';   /* &amp;lt;= instead of word all , the text can contain the word you*/


do i=1 to countw(re,'|');
temp=scan(re,i,'|');
if index(texto,(trim(temp)))&amp;gt;0 then do;
bi="wee";leave;
end;
end;

run;


proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jun 2019 15:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564664#M158409</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-08T15:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564674#M158410</link>
      <description>&lt;P&gt;Thank you Dear&amp;nbsp;&lt;SPAN class="login-bold"&gt;Ksharp and All for your responses &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; it's ok now&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564674#M158410</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-08T15:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a value in text from a variable that contains a list of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564677#M158412</link>
      <description>&lt;P&gt;I think that they are more expensive in terms of cpu usage.... unfortunately I did not find any article that compares re to sas functions ...&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 15:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-value-in-text-from-a-variable-that-contains-a-list-of/m-p/564677#M158412</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-08T15:43:01Z</dc:date>
    </item>
  </channel>
</rss>

