<?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: How to extract the observations contains the another keyword variable and show the keywords matc in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802952#M316151</link>
    <description>&lt;P&gt;If you never want more than one match per &lt;EM&gt;&lt;STRONG&gt;name&lt;/STRONG&gt;&lt;/EM&gt;, then you can put the list of &lt;EM&gt;&lt;STRONG&gt;keyword&lt;/STRONG&gt;&lt;/EM&gt; values into an array of character values.&amp;nbsp; Loop through the array looking for each sequential character expression in &lt;EM&gt;&lt;STRONG&gt;name&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; Stop when one is found, or you've exhausted the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
run;

data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
run;

proc sql noprint;
  select  quote(trim(keywords)) into :keywordlist separated by ',' from keywords;
quit;
%put &amp;amp;=keywordlist;

data want (drop=i);
  set have;
  array kw {&amp;amp;sqlobs} $2 _temporary_ (&amp;amp;keywordlist);
  do i=1 to dim(kw) until (find(name,trim(kw{i}))); end;
  if i&amp;lt;=&amp;amp;sqlobs then keyword=kw{i};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macrovar &lt;EM&gt;&lt;STRONG&gt;keywordlist&lt;/STRONG&gt;&lt;/EM&gt; created by proc sql in the above case is &lt;EM&gt;&lt;STRONG&gt;"ou","vi","oh","ck"&lt;/STRONG&gt;&lt;/EM&gt;, which initializes values in the array &lt;EM&gt;&lt;STRONG&gt;kw&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; &amp;nbsp;The macrovar &lt;EM&gt;&lt;STRONG&gt;SQLOBS&lt;/STRONG&gt;&lt;/EM&gt; is the number of entities generated by the select statement in proc sql.&lt;/P&gt;</description>
    <pubDate>Sun, 20 Mar 2022 02:50:55 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-03-20T02:50:55Z</dc:date>
    <item>
      <title>How to extract the observations contains the another keyword variable and show the keywords matched</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802946#M316147</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you all for contributing the community. I have learnt a lot since I joined.&lt;/P&gt;&lt;P&gt;Here's another issue I encountered. I have two datasets:&lt;/P&gt;&lt;PRE&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
;
run;

data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
;
run;&lt;/PRE&gt;&lt;P&gt;I want to search &lt;STRONG&gt;KEYWORDS.keywords&lt;/STRONG&gt; in &lt;STRONG&gt;HAVE.name&lt;/STRONG&gt; and leave the &lt;STRONG&gt;HAVE&lt;/STRONG&gt; observations only containing the keywords.&lt;/P&gt;&lt;P&gt;AND also show the keywords used in the searching process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I want&lt;/P&gt;&lt;PRE&gt;data want;
   input name $ keywords $;
   datalines; 
John oh
Doug ou
David vi
;
run;&lt;/PRE&gt;&lt;P&gt;Here is just an example, but my actual keywords are more than &lt;STRONG&gt;600&lt;/STRONG&gt;, so I cannot put them all in the code.&lt;/P&gt;&lt;P&gt;Would you please share some codes and thoughts, please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 21:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802946#M316147</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-19T21:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802947#M316148</link>
      <description>&lt;P&gt;This is probably going to be slow for very large data sets ... but it works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table want as select name,keywords 
		from have as a,keywords as b
		where find(a.name,b.keywords,'t')&amp;gt;0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Mar 2022 21:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802947#M316148</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-19T21:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802950#M316150</link>
      <description>&lt;P&gt;What do you want if a name contains more than 1 keyword?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 23:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802950#M316150</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-19T23:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802952#M316151</link>
      <description>&lt;P&gt;If you never want more than one match per &lt;EM&gt;&lt;STRONG&gt;name&lt;/STRONG&gt;&lt;/EM&gt;, then you can put the list of &lt;EM&gt;&lt;STRONG&gt;keyword&lt;/STRONG&gt;&lt;/EM&gt; values into an array of character values.&amp;nbsp; Loop through the array looking for each sequential character expression in &lt;EM&gt;&lt;STRONG&gt;name&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; Stop when one is found, or you've exhausted the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
run;

data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
run;

proc sql noprint;
  select  quote(trim(keywords)) into :keywordlist separated by ',' from keywords;
quit;
%put &amp;amp;=keywordlist;

data want (drop=i);
  set have;
  array kw {&amp;amp;sqlobs} $2 _temporary_ (&amp;amp;keywordlist);
  do i=1 to dim(kw) until (find(name,trim(kw{i}))); end;
  if i&amp;lt;=&amp;amp;sqlobs then keyword=kw{i};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macrovar &lt;EM&gt;&lt;STRONG&gt;keywordlist&lt;/STRONG&gt;&lt;/EM&gt; created by proc sql in the above case is &lt;EM&gt;&lt;STRONG&gt;"ou","vi","oh","ck"&lt;/STRONG&gt;&lt;/EM&gt;, which initializes values in the array &lt;EM&gt;&lt;STRONG&gt;kw&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; &amp;nbsp;The macrovar &lt;EM&gt;&lt;STRONG&gt;SQLOBS&lt;/STRONG&gt;&lt;/EM&gt; is the number of entities generated by the select statement in proc sql.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 02:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802952#M316151</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-20T02:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802953#M316152</link>
      <description>&lt;P&gt;Below two options how this could work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
;

data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
id
;

/* example 1: return first match */
data want_1(drop=_:);
  if _n_=1 then
    do;
      if 0 then set keywords(keep=keywords);
      dcl hash h1(dataset:'keywords');
      dcl hiter hh1('h1');
      h1.defineKey('keywords');
      h1.defineData('keywords');
      h1.defineDone();
    end;
  call missing(of _all_);

  set have;

  _rc = hh1.first();
  do while (_rc = 0);
    if find(name,keywords,'it') then 
      do;
        output;
        leave;
      end;
    _rc = hh1.next();
  end;
run;

/* example 2: return all matches */
data 
    want_2  (keep=row_id name match_flg)
    match_2 (keep=row_id keywords);
    ;
  if _n_=1 then
    do;
      if 0 then set keywords(keep=keywords);
      dcl hash h1(dataset:'keywords');
      dcl hiter hh1('h1');
      h1.defineKey('keywords');
      h1.defineData('keywords');
      h1.defineDone();
    end;
  call missing(of _all_);

  row_id=_n_;
  match_flg=0;
  set have;

  _rc = hh1.first();
  do while (_rc = 0);
    if find(name,keywords,'it') then 
      do;
        output match_2;
        match_flg=1;
      end;
    _rc = hh1.next();
  end;
  output want_2;
/*  if match_flg=1 then output want_2;*/
run;

proc sql;
  select 
    l.*,
    r.keywords
  from want_2 l left join match_2 r
    on l.row_id=r.row_id
  order by row_id
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SQL report using above code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1647732817470.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69587i6E45B13F06F1358C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1647732817470.png" alt="Patrick_0-1647732817470.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 23:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802953#M316152</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-03-19T23:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802963#M316158</link>
      <description>Then show them in two rows of observations.</description>
      <pubDate>Sun, 20 Mar 2022 02:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802963#M316158</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-20T02:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802966#M316160</link>
      <description>&lt;P&gt;To accomodate the possibility of multiple keyword matches for a single name, you have to search for every keyword for every incoming name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
run;

data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
run;

proc sql noprint;
  select  quote(trim(keywords)) into :keywordlist separated by ',' from keywords;
quit;
%put &amp;amp;=keywordlist;

data want (drop=i);
  set have;
  array kw {&amp;amp;sqlobs} $2 _temporary_ (&amp;amp;keywordlist);
  do i=1 to dim(kw) ;
    keyword=kw{i};
    if find(name,trim(keyword)) then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Mar 2022 04:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/802966#M316160</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-20T04:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803010#M316189</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188461"&gt;@yanshuai&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;solutions does take care of the scenario with multiple occurrences of the keywords, is simple and comprehensible.&lt;BR /&gt;I have added more keywords like as follows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $;
   datalines; 
John
Diana
Diane
Sally
Doug
David
Dianna
;
data KEYWORDS;
   input keywords $;
   datalines; 
ou
vi
oh
ck
id
ia
an
;&lt;BR /&gt;/* Following code by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;*/
proc sql;
	create table want as select name,keywords 
		from have as a,keywords as b
		where find(a.name,b.keywords,'t')&amp;gt;0;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output is like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1647816828059.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69594iF4A2B04752229379/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1647816828059.png" alt="Sajid01_0-1647816828059.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 22:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803010#M316189</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-20T22:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803019#M316194</link>
      <description>&lt;P&gt;Thanks for the code. It works well.&lt;/P&gt;&lt;P&gt;What if the keywords must be an individual word, instead of a part of the word, in the NAME&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;PRE&gt;data HAVE;
   input name $char14.;;
   datalines; 
apple LLC
appleLLC
amazon Inc
amazonInc
apple Corp
appleCorp
amazonCorp
;
run;

data KEYWORDS;
   input keywords $;
   datalines; 
apple
amazon
;
run;&lt;/PRE&gt;&lt;P&gt;I want the &lt;STRONG&gt;KEYWORDS&lt;/STRONG&gt; showing up in the &lt;STRONG&gt;NAME&lt;/STRONG&gt; as an individual word (with space before or after), rather than within the NAME string as part of it.&lt;/P&gt;&lt;PRE&gt;data want;
   input name $char11. keywords $char10.;
   datalines; 
apple LLC  apple
apple Corp apple
amazon Inc amazon
;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Mar 2022 03:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803019#M316194</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-21T03:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803020#M316195</link>
      <description>&lt;P&gt;Thanks for the code.&lt;/P&gt;&lt;P&gt;What if the keywords must be an individual word, instead of a part of the word, in the NAME&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;PRE&gt;data HAVE;
   input name $char14.;;
   datalines; 
Apple LLC
AppleLLC
Amazon Inc
AmazonInc
Apple Corp
AppleCorp
AmazonCorp
;
run;


data KEYWORDS;
   input keywords $;
   datalines; 
apple
amazon
;
run;&lt;/PRE&gt;&lt;P&gt;I want the &lt;STRONG&gt;KEYWORDS&lt;/STRONG&gt; showing up in the &lt;STRONG&gt;NAME&lt;/STRONG&gt; as an individual word (with space before or after), rather than within the NAME string as part of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;
   input name $char11. keywords $char10.;
   datalines; 
apple LLC  apple
apple Corp apple
amazon Inc amazon
;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Mar 2022 03:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803020#M316195</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-21T03:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803021#M316196</link>
      <description>&lt;P&gt;Thanks. I love this FIND function.&lt;/P&gt;&lt;P&gt;What if the keywords must be an individual word, instead of a part of the word, in the NAME&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data HAVE;
   input name $char14.;;
   datalines; 
Apple LLC
AppleLLC
Amazon Inc
AmazonInc
Apple Corp
AppleCorp
AmazonCorp
;
run;


data KEYWORDS;
   input keywords $;
   datalines; 
apple
amazon
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want the &lt;STRONG&gt;KEYWORDS&lt;/STRONG&gt; showing up in the &lt;STRONG&gt;NAME&lt;/STRONG&gt; as an individual word (with space before or after), rather than within the NAME string as part of it.&lt;/P&gt;&lt;PRE&gt;data want;
   input name $char11. keywords $char10.;
   datalines; 
apple LLC  apple
apple Corp apple
amazon Inc amazon
;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Mar 2022 03:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803021#M316196</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-21T03:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803055#M316206</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188461"&gt;@yanshuai&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the code. It works well.&lt;/P&gt;
&lt;P&gt;What if the keywords must be an individual word, instead of a part of the word, in the NAME&lt;/P&gt;
&lt;P&gt;For example,&lt;/P&gt;
&lt;PRE&gt;data HAVE;
   input name $char14.;;
   datalines; 
apple LLC
appleLLC
amazon Inc
amazonInc
apple Corp
appleCorp
amazonCorp
;
run;

data KEYWORDS;
   input keywords $;
   datalines; 
apple
amazon
;
run;&lt;/PRE&gt;
&lt;P&gt;I want the &lt;STRONG&gt;KEYWORDS&lt;/STRONG&gt; showing up in the &lt;STRONG&gt;NAME&lt;/STRONG&gt; as an individual word (with space before or after), rather than within the NAME string as part of it.&lt;/P&gt;
&lt;PRE&gt;data want;
   input name $char11. keywords $char10.;
   datalines; 
apple LLC  apple
apple Corp apple
amazon Inc amazon
;
run;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Seems like you didn't even try the code I provided with these different keywords. Please try it and you'll know the answer.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 09:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803055#M316206</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-21T09:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803077#M316218</link>
      <description>&lt;P&gt;If you do not want. to have the names with keywords that are integral to the same, then those names have to filtered out. Better to do it before the Proc SQL step.&lt;/P&gt;
&lt;P&gt;The updated code will be like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   input name $char14.;
 if (find(trim(name),' '))&amp;gt;0;
  datalines; 
apple LLC
appleLLC
amazon Inc
amazonInc
apple Corp
appleCorp
amazonCorp
;
run;

data KEYWORDS;
   input keywords $;
   datalines; 
apple
amazon
;
run;
proc sql;
	create table want as select name,keywords 
		from have as a,keywords as b
		where  find(a.name,b.keywords,'t')&amp;gt;0;
		;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1647871357167.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69613iDA8579BD2C5B903C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1647871357167.png" alt="Sajid01_0-1647871357167.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 14:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803077#M316218</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-21T14:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the observations contains the another keyword variable and show the keywords matc</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803120#M316235</link>
      <description>Actually, I tried it for sure....I am more used to SQL so I tried your code first actually. But I still cannot search out the NAME containing individual KEYWORDS, as my updated reply shows.</description>
      <pubDate>Mon, 21 Mar 2022 15:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-observations-contains-the-another-keyword/m-p/803120#M316235</guid>
      <dc:creator>yanshuai</dc:creator>
      <dc:date>2022-03-21T15:33:35Z</dc:date>
    </item>
  </channel>
</rss>

