<?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: Finding the word number of a list of abbreviations. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269881#M53520</link>
    <description>&lt;P&gt;String1 being searched is '9999&amp;nbsp;CK APPROVED AT A FIXED PAY PROG'.&lt;/P&gt;&lt;P&gt;For FINDW Modifier 'i' or 'I'&amp;nbsp;ignores the case of the characters.&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2016 20:59:15 GMT</pubDate>
    <dc:creator>Lochdonan</dc:creator>
    <dc:date>2016-05-11T20:59:15Z</dc:date>
    <item>
      <title>Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269873#M53516</link>
      <description>&lt;P&gt;I have five diferent words that can have up to five different abreviations that I need to search in String1. Here is an example of 2 of those words that I am searching for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;Inside a Data Step&amp;gt;&lt;BR /&gt;&lt;BR /&gt;IndexFixed = Index(UpCase(String1), 'FIXED');&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'FIXED') &amp;gt; 0 Then Word1 = 'FIXED';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'FIXD') &amp;gt; 0 Then Word1 = 'FIXD';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'FXD') &amp;gt; 0 Then Word1 = 'FXD';&lt;BR /&gt;If Not Missing(Word1) Then Pos1 = FINDW(String1, Word1,' ','I E');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PMT') &amp;gt; 0 Then Word2 = 'PMT';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PYMNT') &amp;gt; 0 Then Word2 = 'PYMNT';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PMNT') &amp;gt; 0 Then Word2 = 'PMNT';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PAY') &amp;gt; 0 Then Word2 = 'PAY';&lt;BR /&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PMNT') &amp;gt; 0 Then Word2 = 'PAYMT';&lt;/P&gt;&lt;P&gt;If Index(UpCase(&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;tring1&lt;/SPAN&gt;), 'PAYMENT') &amp;gt; 0 Then Word2 = 'PAYMENT';&lt;BR /&gt;If Not Missing(Word2) Then Pos2 = FINDW(String2, Word2,' ','E I');&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is repeated for the other 3 words and their abreviations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am finding that only one of the FINDW generated a number to be run. (Pos1-Pos5 only have on value with a number while the other four are zero).&lt;/P&gt;&lt;P&gt;Word1 &amp;nbsp; &amp;nbsp;Word2 &amp;nbsp; &amp;nbsp;Word3 &amp;nbsp; &amp;nbsp;Word4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Word5 &amp;nbsp; &amp;nbsp;Pos1 &amp;nbsp; &amp;nbsp;Pos2 &amp;nbsp; &amp;nbsp;Pos3 &amp;nbsp; &amp;nbsp;Pos4 &amp;nbsp; &amp;nbsp;Pos5&lt;/P&gt;&lt;P&gt;FIXED &amp;nbsp; &amp;nbsp;PAY &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PROG &amp;nbsp; &amp;nbsp;APPR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;Why does FINDW only work once for a given observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 20:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269873#M53516</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T20:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269875#M53517</link>
      <description>&lt;P&gt;You should provide some examples of the values of STRING1 and&amp;nbsp;STRING2&amp;nbsp;to determine exactly why.&lt;/P&gt;
&lt;P&gt;Likely though is that FINDW(String1, Word1,' ','I E'); doesn't use the UPCASE(string1) that was used in the INDEX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 20:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269875#M53517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-11T20:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269880#M53519</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82327"&gt;@Lochdonan﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems odd that you search (the upcased version of) String&lt;STRONG&gt;1&lt;/STRONG&gt; for 'PMT' etc. and then expect to find the word in String&lt;STRONG&gt;2&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 20:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269880#M53519</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T20:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269881#M53520</link>
      <description>&lt;P&gt;String1 being searched is '9999&amp;nbsp;CK APPROVED AT A FIXED PAY PROG'.&lt;/P&gt;&lt;P&gt;For FINDW Modifier 'i' or 'I'&amp;nbsp;ignores the case of the characters.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 20:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269881#M53520</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T20:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269887#M53521</link>
      <description>&lt;P&gt;That is me trying several things (Copying the exact same string to string1 and string2 to find if FINDW works on seperate string variables). Originally I was using the original string and was finding the same results.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269887#M53521</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269893#M53523</link>
      <description>&lt;P&gt;Here are a couple of things to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, only blanks are delimiters.&amp;nbsp; So if you have this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"My problem is fixed.&amp;nbsp; Thank you."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INDEX will find FIXED, but FINDW will not since it is not delimited by blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, unless the length of WORD2 is otherwise defined earlier, it will have a length of 3 (not enough characters to hold some of the values such as "PYMNT" and "PMNT").&amp;nbsp; For those cases, FINDW may not find the abbreviated three-character version as a separate word.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269893#M53523</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-11T21:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269894#M53524</link>
      <description>&lt;P&gt;I do have:&lt;/P&gt;&lt;P&gt;Length Word1 Word2 Word3 Word4 Word5 $20 Pos1 Pos2 Pos3 Pos4 Pos5 Score 8;&lt;/P&gt;&lt;P&gt;earlier. My bad for not including that in the code example.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269894#M53524</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269895#M53525</link>
      <description>&lt;P&gt;Then in the FINDW function, should you replace WORD1 with strip(WORD1)?&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269895#M53525</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-11T21:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269896#M53526</link>
      <description>&lt;P&gt;Or add the R modifier to the last argument of FINDW.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269896#M53526</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T21:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269899#M53528</link>
      <description>&lt;P&gt;even when I define Word1?? &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If Index(UpCase(mlr_data), 'FIXED') &amp;gt; 0 Then Word1 = 'FIXED';&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269899#M53528</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269900#M53529</link>
      <description>&lt;P&gt;Thanks to your LENGTH statement, there will be 15 trailing blanks after "FIXED".&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269900#M53529</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T21:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269901#M53530</link>
      <description>&lt;P&gt;I did try that and got the same result. I would challenge everyone to try this:&lt;BR /&gt;Create a table with one record of Sting1 with value '9999 CK APPROVED FOR A FIXED PAY PROG' and then get the word position of 3 of the words&lt;BR /&gt;for example&lt;BR /&gt;APPROVED at word 3&lt;BR /&gt;FIXED at word 6&lt;BR /&gt;PAY at word 7&lt;BR /&gt;PROG at word 8&lt;/P&gt;&lt;P&gt;That is what I am trying to accomplish. If there is code that can do this... I would be very appreciative.&lt;/P&gt;&lt;P&gt;Thanks again,&lt;BR /&gt;Lochdonan&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269901#M53530</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269902#M53531</link>
      <description>&lt;PRE&gt;1479  data _null_;
1480  length word $20;
1481  retain String1 '9999 CK APPROVED FOR A FIXED PAY PROG';
1482  input word;
1483  pos=findw(string1, word, ' ', 'EIR');
1484  put word 'was found in position ' pos;
1485  cards;

APPROVED was found in position 3
FIXED was found in position 6
PAY was found in position 7
PROG was found in position 8&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 May 2016 21:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269902#M53531</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T21:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269906#M53532</link>
      <description>&lt;P&gt;The R worked... I don't know why. I had done it before but obviously I had done it wrong because adding the R work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU SO MUCH!!!&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269906#M53532</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269907#M53533</link>
      <description>&lt;P&gt;The R worked... I don't know why. I had done it before but obviously I had done it wrong because adding the R work.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;THANK YOU SO MUCH!!!&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 21:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269907#M53533</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T21:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269909#M53534</link>
      <description>&lt;P&gt;Great. (In this case, using the STRIP function should have worked as well.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just one more remark:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This statement&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;If Index(UpCase(String1), 'P&lt;FONT color="#3366FF"&gt;MN&lt;/FONT&gt;T') &amp;gt; 0 Then Word2 = 'P&lt;FONT color="#FF0000"&gt;AYM&lt;/FONT&gt;T';&lt;/PRE&gt;
&lt;P&gt;could cause issues later.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 22:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269909#M53534</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T22:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the word number of a list of abbreviations.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269912#M53535</link>
      <description>&lt;P&gt;Good catch. Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 22:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-word-number-of-a-list-of-abbreviations/m-p/269912#M53535</guid>
      <dc:creator>Lochdonan</dc:creator>
      <dc:date>2016-05-11T22:13:01Z</dc:date>
    </item>
  </channel>
</rss>

