<?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: Searching a string variable for various words in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336580#M63009</link>
    <description>Thank you this absolutely worked, but as you say I will need to look into the code to understand it fully. Thank you for your time.</description>
    <pubDate>Tue, 28 Feb 2017 14:46:28 GMT</pubDate>
    <dc:creator>Dani08</dc:creator>
    <dc:date>2017-02-28T14:46:28Z</dc:date>
    <item>
      <title>Searching a string variable for various words</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336568#M63006</link>
      <description>&lt;P&gt;I have a lookup table of product names (around 200)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;BARKAT&lt;/LI&gt;&lt;LI&gt;CALOGEN&lt;/LI&gt;&lt;LI&gt;CALSHAKE&lt;/LI&gt;&lt;LI&gt;etc.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and I would like to search each of these products through&amp;nbsp;all of my observations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure how to go about this&amp;nbsp;as I am still new to SAS...&lt;/P&gt;&lt;P&gt;I need to do some sort of a scan as the product names do not exactly match up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, when I search for these names in the productname variable, I would like to flag things like...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Barkat brown rice&lt;/LI&gt;&lt;LI&gt;Calogen extra&lt;/LI&gt;&lt;LI&gt;Calogen extra shots&lt;/LI&gt;&lt;LI&gt;Calshake&lt;/LI&gt;&lt;LI&gt;etc.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a cntlin list of the product names, and tried to use indexw/findw, but these seem to require individual words. My list is up to 200, so a manual search is not an option. I wonder if there is a way to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 14:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336568#M63006</guid>
      <dc:creator>Dani08</dc:creator>
      <dc:date>2017-02-28T14:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string variable for various words</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336571#M63007</link>
      <description>&lt;P&gt;This isn't the best topic to be starting to learn with if your new to SAS. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for how to do it, there are a few ways, the way I would go with (and you have not provided any test data in the form of datasteps so this is only an example) - assumes listofwords contains the words, and have contains one string variable called sentance:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set listofwords end=last;
  if _n_=1 then call execute('data want; set have; length wordsfound $2000;');
  call execute('if findw(sentance,"'||strip(word)||'") &amp;gt;0 then wordsfound=catx(",",wordsfound,"'||strip(word)||'");');
  if last then call execute('run;');
run;&lt;/PRE&gt;
&lt;P&gt;What this does is create the datastep code after this is executed, which has an if statement for each word in listofwords, with a catx() function call to add any words found to wordsfound variable. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned this is advanced, not a good area for learning as the above probably doesn't make any sense to you.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 14:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336571#M63007</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-28T14:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string variable for various words</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336580#M63009</link>
      <description>Thank you this absolutely worked, but as you say I will need to look into the code to understand it fully. Thank you for your time.</description>
      <pubDate>Tue, 28 Feb 2017 14:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-a-string-variable-for-various-words/m-p/336580#M63009</guid>
      <dc:creator>Dani08</dc:creator>
      <dc:date>2017-02-28T14:46:28Z</dc:date>
    </item>
  </channel>
</rss>

