<?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: index function for text strings? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377406#M90616</link>
    <description>&lt;P&gt;Assuming you are testing for whole words and there may be more than one wanted, you can try alternative code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
      length word $15; /* addapt to max length word to check */
      i = 1;
      word = lowcase(scan(id01q01txt, i));
      do until (word = ' ');
           if word in ('cost' 'insurance' 'afford'  ...) then reasonmam=1; else
           if word in ('busy' 'availability' 'time' ... ) then reasonmam=2; else
           ... etc. up to ...
           if word in ('age' 'old' 'over' ...) reasonmam=10; 
   
           i+1;       
           word = lowcase(scan(id01q01txt, i));
          
          OUTPUT;   /* any time a word is fitting */
      end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Jul 2017 15:43:27 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-07-19T15:43:27Z</dc:date>
    <item>
      <title>index function for text strings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377373#M90603</link>
      <description>&lt;P&gt;I am trying to create categories from open ended questions.&amp;nbsp; What is the best way to go about this if I want to use full strings?&amp;nbsp; Is there a way to do this without&amp;nbsp;identifying position or case e.g (lowercase)?&amp;nbsp; I have attached code so you guys can get an idea of what I am trying to do, I am sure the index function probably&amp;nbsp;is not&amp;nbsp;the best way to go about this.&amp;nbsp; I basically want to tell say, " if a&amp;nbsp;response in var&amp;nbsp;contains this word and/or string, then var=1 ..."&lt;/P&gt;&lt;P&gt;SAS base 9.4&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 15:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377373#M90603</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2017-07-19T15:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: index function for text strings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377397#M90613</link>
      <description>&lt;P&gt;Two things to consider ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are probably better off using INDEXW rather than INDEX.&amp;nbsp; If you are searching for "dense" SAS looks for those characters.&amp;nbsp; If your longer string were to contain "condense" then INDEX will find "dense", but INDEXW will not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it's easy to apply UPCASE to both arguments with INDEXW so matches can be found regardless of upper vs. lower case.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 15:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377397#M90613</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T15:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: index function for text strings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377406#M90616</link>
      <description>&lt;P&gt;Assuming you are testing for whole words and there may be more than one wanted, you can try alternative code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
      length word $15; /* addapt to max length word to check */
      i = 1;
      word = lowcase(scan(id01q01txt, i));
      do until (word = ' ');
           if word in ('cost' 'insurance' 'afford'  ...) then reasonmam=1; else
           if word in ('busy' 'availability' 'time' ... ) then reasonmam=2; else
           ... etc. up to ...
           if word in ('age' 'old' 'over' ...) reasonmam=10; 
   
           i+1;       
           word = lowcase(scan(id01q01txt, i));
          
          OUTPUT;   /* any time a word is fitting */
      end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 15:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/377406#M90616</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-19T15:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: index function for text strings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/379397#M91322</link>
      <description>&lt;P&gt;I will give this a try. Thank You!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 14:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/index-function-for-text-strings/m-p/379397#M91322</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2017-07-26T14:16:26Z</dc:date>
    </item>
  </channel>
</rss>

