<?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: Find the exact match in string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215462#M39767</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your response, and Patrick above it, both do the same as posted before, just finding any instance of the word Phone with any capitilisation.&amp;nbsp; The OP clearly shows that he only wants one record per instance of the word per the casing present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OP, did you try the code I presented.&amp;nbsp; It assumes that you want the latest in sequence of where a particular capitilisation exists, however you will need to update it to cover spaces as well (as that wasn't in the original test data):&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set new;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_str=scan(str,1," _");&amp;nbsp; /* This here takes the first set of characters up until the underscore or blank, i.e. the first word in any capitilisation */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* This step then works on that first word, outputting the last instance of that string (including upcase or lowcase varieties) */&lt;/P&gt;&lt;P&gt;/* You may actually want to sort the dataset by this word, and the id variable */&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by new_str notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.new_str then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 May 2015 18:00:39 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-05-16T18:00:39Z</dc:date>
    <item>
      <title>Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215454#M39759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am searching for keyword phone .. it could be case insensitive&lt;/P&gt;&lt;P&gt;I have data like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;input number 8. str $20;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 phone&lt;/P&gt;&lt;P&gt;2 Phone_id&lt;/P&gt;&lt;P&gt;3 Phone_num&lt;/P&gt;&lt;P&gt;4 Phone_new&lt;/P&gt;&lt;P&gt;5 Phone&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want output as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 phone &lt;/P&gt;&lt;P&gt;5 Phone&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used Find function and Index function but its producing me all observations. I want exact and case insensitive match. How can it be done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 09:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215454#M39759</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2015-05-15T09:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215455#M39760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you clarify why you want 5 specifically, is it the last value only you want, if so:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set new;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_str=scan(str,1,"_");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by new_str notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.new_str then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 10:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215455#M39760</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-15T10:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215456#M39761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;if upcase(strip(str))='PHONE';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 10:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215456#M39761</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-15T10:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215457#M39762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FINDW to find the WORD phone ignoring case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215457#M39762</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-05-15T11:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215458#M39763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I had thought case was important from the OP, hence I took the delimiter approach rather than string search. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 12:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215458#M39763</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-15T12:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215459#M39764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can we use the Findw ? But somehow i am not getting correct answer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say if my data is something like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data new;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;input number 8. str $200;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cards;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1 phone is not present&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2 Phone_id is not present&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;3 Phone_num is present&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;4 Phone_new is absent&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;5 Phone is present&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;6 PHONE is also there&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;7 pHone is there&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;8 phone_num&amp;nbsp; and phone is not there&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;9 phone_num is present&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output should be &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;1 phone is not present&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;5 Phone is present&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;6 PHONE is also there&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;7 pHone is there&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;8 phone_num&amp;nbsp; and phone is not there&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I am really confused .. what to use and what not. Can we use PRXMATCH for same task&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 May 2015 05:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215459#M39764</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2015-05-16T05:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215460#M39765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once you read in the data correctly using findw() works just fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;input number :8. str :$200.;&lt;/P&gt;&lt;P&gt;if findw(str,'phone',1,' ','i') then output;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 phone is not present&lt;/P&gt;&lt;P&gt;2 Phone_id is not present&lt;/P&gt;&lt;P&gt;3 Phone_num is present&lt;/P&gt;&lt;P&gt;4 Phone_new is absent&lt;/P&gt;&lt;P&gt;5 Phone is present&lt;/P&gt;&lt;P&gt;6 PHONE is also there&lt;/P&gt;&lt;P&gt;7 pHone is there&lt;/P&gt;&lt;P&gt;8 phone_num&amp;nbsp; and phone is not there&lt;/P&gt;&lt;P&gt;9 phone_num is present&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 May 2015 07:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215460#M39765</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-05-16T07:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215461#M39766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes PRXmatch is a good choice \b matches the exact word and i ignores the case&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;infile cards truncover;&lt;/P&gt;&lt;P&gt;input number&amp;nbsp; str $200.;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if prxmatch('/\bphone\b/i',str)&amp;gt;0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 phone is not present&lt;/P&gt;&lt;P&gt;2 Phone_id is not present&lt;/P&gt;&lt;P&gt;3 Phone_num is present&lt;/P&gt;&lt;P&gt;4 Phone_new is absent&lt;/P&gt;&lt;P&gt;5 Phone is present&lt;/P&gt;&lt;P&gt;6 PHONE is also there&lt;/P&gt;&lt;P&gt;7 pHone is there&lt;/P&gt;&lt;P&gt;8 phone_num and phone is not there&lt;/P&gt;&lt;P&gt;9 phone_num is present&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 May 2015 09:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215461#M39766</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-05-16T09:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215462#M39767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your response, and Patrick above it, both do the same as posted before, just finding any instance of the word Phone with any capitilisation.&amp;nbsp; The OP clearly shows that he only wants one record per instance of the word per the casing present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OP, did you try the code I presented.&amp;nbsp; It assumes that you want the latest in sequence of where a particular capitilisation exists, however you will need to update it to cover spaces as well (as that wasn't in the original test data):&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set new;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_str=scan(str,1," _");&amp;nbsp; /* This here takes the first set of characters up until the underscore or blank, i.e. the first word in any capitilisation */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* This step then works on that first word, outputting the last instance of that string (including upcase or lowcase varieties) */&lt;/P&gt;&lt;P&gt;/* You may actually want to sort the dataset by this word, and the id variable */&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by new_str notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.new_str then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 May 2015 18:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215462#M39767</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-16T18:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215463#M39768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just some suggestions, not tested by coding:&lt;/P&gt;&lt;P&gt;Can you first create two additional variables, VAR1 and VAR2 to hold the first word and the rest words of "str" respectively; then standardize the VAR1 by using function "upcase". After doing this, chose based on two conditions, (1) VAR1 = "PHONE" and (2) VAR2 = " " ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 09:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/215463#M39768</guid>
      <dc:creator>HHZ</dc:creator>
      <dc:date>2015-05-19T09:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find the exact match in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/387934#M93041</link>
      <description>worked like a charm. i used your suggestion with macro variable with no problem</description>
      <pubDate>Mon, 14 Aug 2017 19:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-exact-match-in-string/m-p/387934#M93041</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-08-14T19:30:10Z</dc:date>
    </item>
  </channel>
</rss>

