<?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 keywords from one list in variable string in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542253#M7522</link>
    <description>&lt;P&gt;If I understand this right then it's you who is populating a macro variable with a list of words. If so then why don't you just use something else than a comma as delimiter between the words. You could for example use a pipe character (|);&lt;/P&gt;
&lt;P&gt;Then just use this pipe character in the scan() function.&lt;/P&gt;
&lt;PRE&gt;scan("&amp;amp;samplelist",i,'|')&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2019 00:54:01 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-03-12T00:54:01Z</dc:date>
    <item>
      <title>Finding keywords from one list in variable string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542184#M7502</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying to get SAS to read through a list of keywords that are saved in an excel spreadsheet and then search for those words in variables from a sas dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I've been doing is using setting those words into a macro and then using the "scan" and "findw" functions to search for the words. (code below). This was working fine until I realized that some of my words in the list have comma's in between them. An example of this problem is we might have the word "1,3-monocytocane" and the variable may have the following reported: "Out of those present 1 had fun." In this case, the "1" would be captured as a keyword and new_var would then equal 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have over 100 words and I can't change the way they are written. I've tried creating a few proc sql to tackle the problem, but I'm not getting what I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select words into:samplelist separated by ','
from wordlist
where words ne "" ;
quit;
%put &amp;amp;samplelist;

data temp2;
set temp1;
	new_var=1;
	i=1;
	do while ((scan("&amp;amp;samplelist",i,",") ne '') and new_var&amp;gt;0);		
	  i+1;															
	  name=scan("&amp;amp;samplelist",i-1,",");							
	  indx_var=findw(lowcase(old_var),compress(lowcase(name)));
	if indx_var&amp;gt;0 
		then new_var=0; 	
		else new_var=new_var+1;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any advice would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 19:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542184#M7502</guid>
      <dc:creator>JoanneR</dc:creator>
      <dc:date>2019-03-11T19:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding keywords from one list in variable string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542253#M7522</link>
      <description>&lt;P&gt;If I understand this right then it's you who is populating a macro variable with a list of words. If so then why don't you just use something else than a comma as delimiter between the words. You could for example use a pipe character (|);&lt;/P&gt;
&lt;P&gt;Then just use this pipe character in the scan() function.&lt;/P&gt;
&lt;PRE&gt;scan("&amp;amp;samplelist",i,'|')&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 00:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542253#M7522</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-12T00:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding keywords from one list in variable string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542272#M7525</link>
      <description>&lt;P&gt;This wouldn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table temp2 as
select
    old_var,
    words
from 
    temp1 as a left join 
    wordlist as b
on findw(old_var, words, " ", "sti")) &amp;gt; 0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Mar 2019 04:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-keywords-from-one-list-in-variable-string/m-p/542272#M7525</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-12T04:15:44Z</dc:date>
    </item>
  </channel>
</rss>

