<?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: Find all the variables that contains the words of a list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634705#M188403</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/318505"&gt;@Kendrew&lt;/a&gt;&amp;nbsp; yet another similar one alike others using FIND function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data words;
input dummy WORDS $;
cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;
data have;
input (COMPANY PROD1 PROD2 PROD3) ($);
cards;
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

data want;
 if _n_=1 then do;
  if 0 then set words;
   dcl hash H (dataset: "words") ;
   h.definekey  ("words") ;
   h.definedone () ;
   dcl hiter hi('h');
 end;
 set have;
 length temp $500;
 temp=catx(' ',of prod1-prod3);
 do while(hi.next()=0);
  if find(temp,strip(words)) then _n_=0;
 end;
 if _n_=0;
 keep company prod1-prod3;
run;

 
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;COMPANY&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD3&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C1&lt;/TD&gt;
&lt;TD class="l data"&gt;FAAAC&lt;/TD&gt;
&lt;TD class="l data"&gt;FQQQ&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C3&lt;/TD&gt;
&lt;TD class="l data"&gt;FOOOC&lt;/TD&gt;
&lt;TD class="l data"&gt;FBBB&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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, 25 Mar 2020 11:45:28 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-03-25T11:45:28Z</dc:date>
    <item>
      <title>Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634660#M188384</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have been working on a task, and i need to find those variables that contain the words of a list.&lt;BR /&gt;Lets say&lt;BR /&gt;&lt;BR /&gt;ITEM WORDS&lt;BR /&gt;1 AAA&lt;BR /&gt;2 BBB&lt;BR /&gt;3 CCC&lt;BR /&gt;4 DDD&lt;BR /&gt;5 EEE&lt;BR /&gt;&lt;BR /&gt;COMPANY PROD1 PROD2 PROD3&lt;BR /&gt;C1 FAAAC FQQQ FPPP FZZZ&lt;BR /&gt;C2 FTTTW FUUU FPPP FLLL&lt;BR /&gt;C3 FOOOC FBBB FPPP FMMM&lt;BR /&gt;C4 FIIIIC FOOO FPPP FLLL&lt;BR /&gt;&lt;BR /&gt;And i want to have the result like&lt;BR /&gt;&lt;BR /&gt;COMPANY PROD1 PROD2 PROD3&lt;BR /&gt;C1 FAAAC FQQQ FPPP FZZZ&lt;BR /&gt;C3 FOOOC FBBB FPPP FMMM&lt;BR /&gt;&lt;BR /&gt;as the product name in company C1 and C3 hit the words of the list.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Mar 2020 09:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634660#M188384</guid>
      <dc:creator>Kendrew</dc:creator>
      <dc:date>2020-03-25T09:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634662#M188386</link>
      <description>And supposed that there are 50 words on the list</description>
      <pubDate>Wed, 25 Mar 2020 10:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634662#M188386</guid>
      <dc:creator>Kendrew</dc:creator>
      <dc:date>2020-03-25T10:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634684#M188396</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data words;
input dummy WORDS $;
cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;
data have;
input (COMPANY PROD1 PROD2 PROD3) ($);
cards;
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

options noquotelenmax;
proc sql noprint;
select words into :words separated by '|' from words;
quit;
data want;
 set have;
 if prxmatch("/&amp;amp;words/",catx('|',of prod:));
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 10:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634684#M188396</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-25T10:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634688#M188397</link>
      <description>&lt;P&gt;Your company-dataset seems to consist of four variables, but the subsequent lines have five values. So please post the data you have in usable form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 10:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634688#M188397</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-25T10:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634691#M188398</link>
      <description>&lt;P&gt;Similar to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; 's but no macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORDS;
  input ITEM WORD $;
cards;  
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
run;

data COMPANIES;
  input COMPANY $ PROD1 $ PROD2 $ PROD3 $;
cards;  
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
run;

data WANT;
  length WORDS $800;
  retain WORDS PRX;
  if _N_=1 then do;
    do I= 1 by 1 until(LASTOBS);
      set WORDS end=LASTOBS;
      WORDS=catx('|',WORDS,WORD);
    end;
    PRX=prxparse(catt('/',WORDS,'/'));
  end;
  set COMPANIES;
  if prxmatch(PRX,catx('|',of PROD1-PROD3));
  drop I WORD: ;
run;  

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="sasLogNote7_1585133751927" class="sasNote" style="color: blue; font-family: Consolas, Courier, 'Courier New'; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial;"&gt;NOTE: The data set WORK.WANT has 2 observations and 6 variables.&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 23:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634691#M188398</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-25T23:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634705#M188403</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/318505"&gt;@Kendrew&lt;/a&gt;&amp;nbsp; yet another similar one alike others using FIND function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data words;
input dummy WORDS $;
cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;
data have;
input (COMPANY PROD1 PROD2 PROD3) ($);
cards;
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

data want;
 if _n_=1 then do;
  if 0 then set words;
   dcl hash H (dataset: "words") ;
   h.definekey  ("words") ;
   h.definedone () ;
   dcl hiter hi('h');
 end;
 set have;
 length temp $500;
 temp=catx(' ',of prod1-prod3);
 do while(hi.next()=0);
  if find(temp,strip(words)) then _n_=0;
 end;
 if _n_=0;
 keep company prod1-prod3;
run;

 
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;COMPANY&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD3&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C1&lt;/TD&gt;
&lt;TD class="l data"&gt;FAAAC&lt;/TD&gt;
&lt;TD class="l data"&gt;FQQQ&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C3&lt;/TD&gt;
&lt;TD class="l data"&gt;FOOOC&lt;/TD&gt;
&lt;TD class="l data"&gt;FBBB&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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, 25 Mar 2020 11:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634705#M188403</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-25T11:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634711#M188405</link>
      <description>&lt;P&gt;And yet another way for doing this creating a RegEx informat from your Words table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* source data */
data words;
  input dummy WORDS $;
  cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;

data have;
  input (COMPANY PROD1 PROD2 PROD3) ($);
  cards;
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

/* create informat using regex */
data strings_fmt;
  retain fmtname 'match_strings';
  retain default 10;
  retain type 'I';
  retain HLO 'SP';
  length start $20;
  retain label 1;
  set words(keep=words) end=last;
  start=cats('/',words,'/i');
  output;
  if last then
    do;
      hlo='SO';
      label=0;
      output;
    end;
run;

proc format cntlin=strings_fmt;
run;


/* select rows with matching strings */
data want;
  set have;
  array _prod prod1-prod3;
  do over _prod;
    /* string found if informat returns 1 */
    if input(_prod,match_strings.) = 1 then
      do;
        output;
        leave;
      end;
  end;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1585137446452.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37349i74EF9978BB52E840/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1585137446452.png" alt="Patrick_0-1585137446452.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634711#M188405</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-25T12:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634714#M188406</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data words;
input dummy WORDS $;
cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;
data have;
input (COMPANY PROD1 PROD2 PROD3) ($);
cards;
C1 FAAAC FQQQ FPPP FZZZ
C2 FTTTW FUUU FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

proc sql;
 create table want as
 select a.*
 from have a, words
 where  index(catx(prod1,prod2,prod3),strip(words))&amp;gt;0;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;COMPANY&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;PROD3&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C1&lt;/TD&gt;
&lt;TD class="l data"&gt;FAAAC&lt;/TD&gt;
&lt;TD class="l data"&gt;FQQQ&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;C3&lt;/TD&gt;
&lt;TD class="l data"&gt;FOOOC&lt;/TD&gt;
&lt;TD class="l data"&gt;FBBB&lt;/TD&gt;
&lt;TD class="l data"&gt;FPPP&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634714#M188406</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-25T12:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634722#M188409</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe your SQL needs below two amendments.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1585139008201.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37352i7C039F532E455DC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1585139008201.png" alt="Patrick_0-1585139008201.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634722#M188409</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-25T12:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634723#M188410</link>
      <description>&lt;P&gt;Thank you sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp; though catx without delimiter in a SQL is kinda tolerant to work like cats &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But like you pointed better to be safe than sorry, and with a tweak to handle multiple matches(if present)&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 distinct a.*
 from have a, words
 group by COMPANY,PROD1, PROD2, PROD3
 having max(index(catx('|',prod1,prod2,prod3),strip(words)));
quit;&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, 25 Mar 2020 12:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634723#M188410</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-25T12:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634727#M188411</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp; though catx without delimiter in a SQL is kinda tolerant to work like cats &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You sure about this? Then can you explain below result?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data words;
  input dummy WORDS $;
  cards;
1 AAA
2 BBB
3 CCC
4 DDD
5 EEE
;

data have;
  input (COMPANY PROD1 PROD2 PROD3) ($);
  cards;
C1 FAAAC FBBB FPPP FZZZ
C2 DTTTA AADD FPPP FLLL
C3 FOOOC FBBB FPPP FMMM
C4 FIIIIC FOOO FPPP FLLL
;

proc sql;
/*  create table want as*/
  select 
    a.*,
    catx(prod1,prod2,prod3) as str1,
    catx('|',prod1,prod2,prod3) as str2
  from have a, words
  group by COMPANY,PROD1, PROD2, PROD3
  having max(index(catx(prod1,prod2,prod3),strip(words)));
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1585139958085.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37353i1519559A98E18FB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1585139958085.png" alt="Patrick_0-1585139958085.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634727#M188411</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-25T12:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634729#M188412</link>
      <description>&lt;P&gt;Right I see. Sorry for my misconception/misunderstanding. I take back my words. My apologies.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I sit corrected. Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634729#M188412</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-25T12:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find all the variables that contains the words of a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634732#M188413</link>
      <description>&lt;P&gt;It was a nice one. Made me realize that I can use a variable as delimiter. Can't think of a use case right now - but who knows.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set sashelp.class;
  string=catx(sex,age,height,weight);
run;
proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1585140460823.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37354i7C88763F9CF56C79/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1585140460823.png" alt="Patrick_0-1585140460823.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-all-the-variables-that-contains-the-words-of-a-list/m-p/634732#M188413</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-25T12:48:05Z</dc:date>
    </item>
  </channel>
</rss>

