<?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: match the exact same word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907709#M358312</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you so much for your code. I managed to solve my problem using the following codes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data education; 
	set org.na_dir_profile_education;
	if findw(upcase(qualification), 'BACHELOR')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), "BACHELOR'S DEGREE")&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BSC')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BE')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BSE')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BENG')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BA')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'B Acc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B Arch')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Acc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Math')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Proc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BAS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BASc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BAppSc')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'BArch')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBM')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCL')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCom')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BComm')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'BCompt')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEcon')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEd')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BFA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BInf')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BInfTech')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BJ')&amp;gt;=1 then bachelor = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May I know if there is simplified way like writing a macro to shorten the above, as there are at least 30-40 qualified words for my bachelor indicator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 06:29:26 GMT</pubDate>
    <dc:creator>Jarvin99</dc:creator>
    <dc:date>2023-12-13T06:29:26Z</dc:date>
    <item>
      <title>match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907697#M358307</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would say I am very new to SAS...so please kindly help me. I am struggling with a very simple task. I want to be able to identify people with a bachelor's degree. Below is the sample of the data:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;people&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;obtain_year&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;qualification&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Tom&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1990&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;BA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Tom&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2002&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;master&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Tom&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2010&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;MBA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Alice&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;1994Jan&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;bachelor's degree&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Alice&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2011&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;EMBA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Lou&lt;/TD&gt;
&lt;TD&gt;2005&lt;/TD&gt;
&lt;TD&gt;BS&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Lou&lt;/TD&gt;
&lt;TD&gt;2006Jun01&lt;/TD&gt;
&lt;TD&gt;MSc&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Lou&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2012&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;master of business administration&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My desired outcome should create columns of indicators flagging who has bachelor, master, and MBA degrees, regardless of the uppercase and lowercase.&lt;/P&gt;
&lt;TABLE border="1" width="1000px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;people&lt;/TD&gt;
&lt;TD width="322.453px"&gt;obtain_year&lt;/TD&gt;
&lt;TD width="160.891px"&gt;qualification&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;bachelor&lt;/TD&gt;
&lt;TD width="40px"&gt;master&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;MBA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Tom&lt;/TD&gt;
&lt;TD width="322.453px"&gt;1990&lt;/TD&gt;
&lt;TD width="160.891px"&gt;BA&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;1&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Tom&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2002&lt;/TD&gt;
&lt;TD width="160.891px"&gt;master&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="40px"&gt;1&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Tom&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2010&lt;/TD&gt;
&lt;TD width="160.891px"&gt;MBA&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Alice&lt;/TD&gt;
&lt;TD width="322.453px"&gt;1994Jan&lt;/TD&gt;
&lt;TD width="160.891px"&gt;bachelor's degree&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;1&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Alice&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2011&lt;/TD&gt;
&lt;TD width="160.891px"&gt;EMBA&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Lou&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2005&lt;/TD&gt;
&lt;TD width="160.891px"&gt;BS&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;1&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Lou&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2006Jun01&lt;/TD&gt;
&lt;TD width="160.891px"&gt;MSc&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="40px"&gt;1&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="322.359px"&gt;Lou&lt;/TD&gt;
&lt;TD width="322.453px"&gt;2012&lt;/TD&gt;
&lt;TD width="160.891px"&gt;master of business administration&lt;/TD&gt;
&lt;TD width="73.3594px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="79.9375px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using 'findw' and 'index', but these functions will pick 'MBA' as well when I only want to include 'BA'. Bachelor degrees should be equal to 1 when the qualification contains the exact words: 'bachelor', 'BA', 'BS', or 'bachelor's degree'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for your assistance in advance, as I really need to get this done soon in order for the next step of my research.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 03:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907697#M358307</guid>
      <dc:creator>Jarvin99</dc:creator>
      <dc:date>2023-12-13T03:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907700#M358309</link>
      <description>&lt;P&gt;Please provide sample data in the form of a working DATA step, and the sas code you are using.&amp;nbsp; &amp;nbsp;You'll get better advice, and (likely) tested code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, using FINDW (find &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;word&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;) to detect the unigram 'BA' should not give a false positive searching a string containing 'MBA'.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 04:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907700#M358309</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-12-13T04:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907704#M358311</link>
      <description>&lt;P&gt;Code not tested because there was no ready-made sample data but should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length Batchelor Master MBA $1;
  if findw(qualification,'ba','it')&amp;gt;0             then Batchelor='1';
  else if findw(qualification,'bachelor','it')&amp;gt;0  then Batchelor='1';
  else if findw(qualification,'master','it')&amp;gt;0    then Master='1';
  else if findw(qualification,'mba','it')&amp;gt;0       then MBA='1';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 05:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907704#M358311</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-13T05:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907709#M358312</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you so much for your code. I managed to solve my problem using the following codes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data education; 
	set org.na_dir_profile_education;
	if findw(upcase(qualification), 'BACHELOR')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), "BACHELOR'S DEGREE")&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BSC')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BE')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BSE')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BENG')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BA')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'B Acc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B Arch')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Acc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Math')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Proc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BAS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BASc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BAppSc')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'BArch')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBM')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BBS')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCL')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BCom')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BComm')&amp;gt;=1 then bachelor = 1;

	if findw(upcase(qualification), 'BCompt')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEcon')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BEd')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BFA')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BInf')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BInfTech')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BJ')&amp;gt;=1 then bachelor = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May I know if there is simplified way like writing a macro to shorten the above, as there are at least 30-40 qualified words for my bachelor indicator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 06:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907709#M358312</guid>
      <dc:creator>Jarvin99</dc:creator>
      <dc:date>2023-12-13T06:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907720#M358313</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415810"&gt;@Jarvin99&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;....&lt;BR /&gt;May I know if there is simplified way like writing a macro to shorten the above, as there are at least 30-40 qualified words for my bachelor indicator?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There might be options to write something dynamic but if and what really is suitable for your data depends on what you have and your search terms.&lt;/P&gt;
&lt;P&gt;You were talking about searching for WORD (not strings that can be part of a word) but looking into your code there might be some challenges what defines a word delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example based on below it appears both a blank and a fullstop can't always serve as word delimiter.&lt;/P&gt;
&lt;P&gt;To create something dynamic the code logic would need to "know" when it can't use the normal word delimiters and what can serve as delimiter.&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;	if findw(upcase(qualification), 'B Acc')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B Arch')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'B.Acc')&amp;gt;=1 then bachelor = 1;&lt;/LI-CODE&gt;
&lt;P&gt;If you have a series of IF statements that are exclusive then use ELSE IF. There is really no need to execute all the IF's after an expression returns true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of above 3 expressions will ever return TRUE because if not explicitly specified via a parameter findw() will use blank and fullstop as word delimiters and though can never find a term that contains such a word delimiter. You also don't need to upcase the source variable if you use the findw() "i" modifier that instructs the function to search case &lt;STRONG&gt;i&lt;/STRONG&gt;nsensitive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1702460650097.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91245i5A567DC1D7C796E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1702460650097.png" alt="Patrick_0-1702460650097.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;characters&lt;/EM&gt;&amp;nbsp;in findw() let's you define explicitly what to use as word delimiters if you can't use the default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you read in the docu the details about the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p16rdsa30vmm43n1ej4936nwa01t.htm#p0duxydh7j4xejn1oytcxoenzm5u" target="_self"&gt;findw() function&lt;/A&gt; to fully understand what functionality is available and then investigate your search terms to identify the challenges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 09:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907720#M358313</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-13T09:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907805#M358336</link>
      <description>&lt;P&gt;Perhaps:&lt;/P&gt;
&lt;PRE&gt;data education; 
 set org.na_dir_profile_education;
 if upcase(qualification) in ( 'BACHELOR'
 "BACHELOR'S DEGREE" 'BS' 'BSC' 'BE' 'BSE' 'BENG' 'BA'
 'B ACC' 'B ARCH' 'B.ACC' 'B.MATH' 'B.PROC' 'BAS' 'BASC' 'BAPPSC' 
 'BARCH' 'BBA' 'BBM' 'BBS' 'BCA' 'BCL' 'BCOM' 'BCOMM' 
 'BCOMPT' 'BEC' 'BECON' 'BED' 'BFA' 'BINF' 'BINFTECH' 'BJ' 
 ) then bachelor=1;
run;&lt;/PRE&gt;
&lt;P&gt;will reduce some of your coding since you apparently have WAY MORE values than your question stated.&lt;/P&gt;
&lt;P&gt;Not to mention that several of your FINDW were looking for not upcased value in the search string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Findw does have the i optional modifier to ignore case.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907805#M358336</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-13T16:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907815#M358337</link>
      <description>&lt;P&gt;Note that for FINDW() (and other WORD finding functions) it is perfectly fine to search for "words" that contain delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;findw(string,'Word1 word2',' ','i')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will find WORD1 followed by a single space and WORD2 that is either at the beginning or end of the string or between two spaces.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907815#M358337</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-13T16:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: match the exact same word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907948#M358363</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415810"&gt;@Jarvin99&lt;/a&gt;&amp;nbsp; wrote:&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you so much for your code. I managed to solve my problem using the following codes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data education; 
	set org.na_dir_profile_education;
	if findw(upcase(qualification), 'BACHELOR')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), "BACHELOR'S DEGREE")&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BS')&amp;gt;=1 then bachelor = 1;
    ... many lines deleted ...&lt;BR /&gt;	if findw(upcase(qualification), 'BInfTech')&amp;gt;=1 then bachelor = 1;
	if findw(upcase(qualification), 'BJ')&amp;gt;=1 then bachelor = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May I know if there is simplified way like writing a macro to shorten the above, as there are at least 30-40 qualified words for my bachelor indicator?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to the comments others have made about using ELSE IF construct's to avoid doing superfluous IF test's, you should consider using a _TEMPORARY array of the search terms as a code-saving device, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data education (drop=i _:); 
	set org.na_dir_profile_education;

     array _text_ba {10} $20 _temporary_
       ('BACHELOR','BS','BSC','BE','BSE','BENG','BA',
        'BAS','BASc','BAppSc')

     bachelor=0;
     do i=1 to dim(_text_ba) until (bachelor=1);
       bachelor=(findw(_upcase_qual,trim(_unigrams_ba{i}))&amp;gt;=1);
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above ignores upper/lower case issues, which are easily addressed.&amp;nbsp; More important is the issue of searching for two-word phrases ("bigrams" in this note.&amp;nbsp; One-word phrases are unigrams). FINDW is not meant to find them.&amp;nbsp; Here's a workaround, which divides your search terms into unigrams and bigrams:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data education (drop=i _:); 
	set org.na_dir_profile_education;
	set have;

     array _unigrams_ba {26} $20 _temporary_
       ('BACHELOR','BS','BSC','BE','BSE','BENG','BA',
        'BAS','BASc','BAppSc','BArch','BBA','BBM','BBS','BCA',
        'BCL','BCom','BComm','BCompt','BEc','BEcon','BEd','BFA',
        'BInf','BInfTech','BJ');

     array _bigrams_ba {6} $20 _temporary_
       ("BACHELOR'S DEGREE",'B Acc','B Arch','B.Acc','B.Math','B.Proc');

     /*Make everything upper-case, for finding purposes */
     _upcase_qual=upcase(qualification);
     if _n_=1 then do;
       do i=1 to dim(_unigrams_ba);  unigrams_ba{i}=upcase(_unigrams_ba{i}); end;
       do i=1 to dim(_bigrams_ba);   bigrams_ba{i}=upcase(_bigrams_ba{i}); end;
     end;

     bachelor=0;
     do i=1 to dim(_unigrams_ba) until (bachelor=1);
       bachelor=(findw(_upcase_qual,trim(_unigrams_ba{i}))&amp;gt;=1);
     end;

     if bachelor=0 then do i=1 to dim(_bigrams_ba) until (bachelor=1);
       _w1=findw(_upcase_qual,trim(scan(_bigrams_ba{i},1)),' .','e');
       _w2=findw(_upcase_qual,trim(scan(_bigrams_ba{i},2)),' .','e');
       bachelor=(_w2=_w1+1) and (_w1&amp;gt;0);          
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "trick" here in dealing with bigrams is to use a feature of FINDW (the 'e' as the 4th parameter of FINDW) that returns the word-sequence number rather than the character position of a search-word inside a string-of-words.&amp;nbsp; The benefit is that if you are searching for "Bachelor's degree", you want to know if the word number of "degree" is one greater than the word number of "Bachelor's".&amp;nbsp; &amp;nbsp;Of course, that is not bullet proof, since it doesn't protect against any of the words appearing more than once, masking detection of the proper sequence.&amp;nbsp; Code can be written to avoid this, but this code is a little more self-evident.&amp;nbsp;&amp;nbsp; &amp;nbsp; The third argument of FINDW&amp;nbsp; ( ' .') tells the function that only those two characters are word delimiters.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 21:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-the-exact-same-word/m-p/907948#M358363</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-12-13T21:27:01Z</dc:date>
    </item>
  </channel>
</rss>

