<?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 a word in a character string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280829#M56820</link>
    <description>&lt;P&gt;While INDEX is the right tool, it has to be used wisely.&amp;nbsp; For example, this would be lazy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index('KWk 45', 'Wk 4') then period=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INDEX function will find "Wk 4" and will set PERIOD to 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More careful use would append a blank at the beginning and end of both strings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(' KWk 45 ', ' Wk 4 ') then period=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now INDEX is searching for a 6-character string, and doesn't find it.&amp;nbsp; Using your VISIT variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(' ' || visit || ' ', ' Wk 4 ') then period=1;&lt;/P&gt;
&lt;P&gt;else if index(' ' || visit || ' ', ' UNSCHEDULED ') then period=2;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2016 15:52:24 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-06-28T15:52:24Z</dc:date>
    <item>
      <title>How to find a word in a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280767#M56792</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to find a word in character string and assign values to another variable. I have visit variable. I need to assign values to period variable.Please help. Thank&lt;/P&gt;
&lt;P&gt;eg; if visit contains word 'Wk 4' then period=1;&lt;/P&gt;
&lt;P&gt;else if visit contains word '&lt;SPAN&gt;UNSCHEDULED' then period=2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;visit&lt;/P&gt;
&lt;P&gt;Day 28&amp;amp;29 +/- 3 Wk 4&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Day 27&amp;amp;28 +/- 3 Wk 4&lt;/P&gt;
&lt;P&gt;UNSCHEDULED VISIT 1.01&lt;/P&gt;
&lt;P&gt;UNSCHEDULED VISIT 2.01&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280767#M56792</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-06-29T12:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to a word in a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280771#M56795</link>
      <description>&lt;P&gt;Have a look at the &lt;A href="https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#n0vxokxhv8lr84n10nrbnzp7gnba.htm" target="_blank"&gt;index&lt;/A&gt; function.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 13:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280771#M56795</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-28T13:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to a word in a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280829#M56820</link>
      <description>&lt;P&gt;While INDEX is the right tool, it has to be used wisely.&amp;nbsp; For example, this would be lazy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index('KWk 45', 'Wk 4') then period=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INDEX function will find "Wk 4" and will set PERIOD to 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More careful use would append a blank at the beginning and end of both strings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(' KWk 45 ', ' Wk 4 ') then period=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now INDEX is searching for a 6-character string, and doesn't find it.&amp;nbsp; Using your VISIT variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(' ' || visit || ' ', ' Wk 4 ') then period=1;&lt;/P&gt;
&lt;P&gt;else if index(' ' || visit || ' ', ' UNSCHEDULED ') then period=2;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 15:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-word-in-a-character-string/m-p/280829#M56820</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-28T15:52:24Z</dc:date>
    </item>
  </channel>
</rss>

