<?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: Help using index function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755125#M238232</link>
    <description>&lt;P&gt;INDEXW or FINDW to find &lt;STRONG&gt;words&lt;/STRONG&gt;. Index and Find will find strings embedded in longer words.&lt;/P&gt;
&lt;PRE&gt;DATA TWO;
SET ONE;
IF indexw(UPCASE(A),'OTHER');
RUN;&lt;/PRE&gt;
&lt;P&gt;Indexw has an optional parameter for providing delimiters between words in case the blank is not sufficient. Suppose you have text like: this*that=something.&lt;/P&gt;
&lt;P&gt;If you want to find "that" as a word you could provide * and = as additional delimiters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if indexw(str,'that',' *=') then ...&lt;/P&gt;
&lt;P&gt;Note the inclusion of the blank so that other places blank is still used as a delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Findw is similar but has a few more parameters and can use modifiers to indicate things like "all punctuation" and Ignore case for comparisons.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jul 2021 14:41:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-07-20T14:41:03Z</dc:date>
    <item>
      <title>Help using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755105#M238224</link>
      <description>&lt;P&gt;Dear&lt;/P&gt;
&lt;P&gt;I need help in my pgm to output only records that contain 'OTHER'. In the my data, there is one record with 'OTHER'. In the output dataset 'TWO'&amp;nbsp; I am getting three records. Please suggest&lt;/P&gt;
&lt;PRE&gt;data one;&lt;BR /&gt;input a $40.;&lt;BR /&gt;datalines;&lt;BR /&gt;contains OTHER&lt;BR /&gt;contains CHEMOTHERAPY&lt;BR /&gt;contains IMMUNOTHERAPY&lt;BR /&gt;contains IMMUNO&lt;BR /&gt;;&lt;BR /&gt;DATA TWO;&lt;BR /&gt;SET ONE;&lt;BR /&gt;IF index(UPCASE(A),'OTHER');&lt;BR /&gt;RUN;&lt;/PRE&gt;
&lt;P&gt;output need&lt;/P&gt;
&lt;P&gt;contains OTHER&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 19:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755105#M238224</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2021-07-19T19:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755115#M238229</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68272"&gt;@knveraraju91&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;chemOTHERapy and immunOTHERapy also contain the string 'OTHER' of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe this code helps you out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a $40.;
datalines;
contains OTHER
contains CHEMOTHERAPY
contains IMMUNOTHERAPY
contains IMMUNO
;
run;

DATA TWO;
SET ONE;
where scan(upcase(a),2)='OTHER'; 
*IF index(UPCASE(A),'OTHER');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 20:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755115#M238229</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-07-19T20:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help using index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755125#M238232</link>
      <description>&lt;P&gt;INDEXW or FINDW to find &lt;STRONG&gt;words&lt;/STRONG&gt;. Index and Find will find strings embedded in longer words.&lt;/P&gt;
&lt;PRE&gt;DATA TWO;
SET ONE;
IF indexw(UPCASE(A),'OTHER');
RUN;&lt;/PRE&gt;
&lt;P&gt;Indexw has an optional parameter for providing delimiters between words in case the blank is not sufficient. Suppose you have text like: this*that=something.&lt;/P&gt;
&lt;P&gt;If you want to find "that" as a word you could provide * and = as additional delimiters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if indexw(str,'that',' *=') then ...&lt;/P&gt;
&lt;P&gt;Note the inclusion of the blank so that other places blank is still used as a delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Findw is similar but has a few more parameters and can use modifiers to indicate things like "all punctuation" and Ignore case for comparisons.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 14:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-using-index-function/m-p/755125#M238232</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-20T14:41:03Z</dc:date>
    </item>
  </channel>
</rss>

