<?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 count double-barrel name as one word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-double-barrel-name-as-one-word/m-p/821516#M324328</link>
    <description>&lt;P&gt;This should correct your word counting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  full_name = 'Mr James Headey-Greaves';
  word_count = countw(full_name,,'AL');
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Jul 2022 01:00:34 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-07-05T01:00:34Z</dc:date>
    <item>
      <title>How to count double-barrel name as one word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-double-barrel-name-as-one-word/m-p/821514#M324327</link>
      <description>&lt;P&gt;Can someone tell me how I would change my code to accommodate for double-barrelled names? I am creating a new variable called 'Middle_Initial' and trying to get the first letter of the first middle name (if someone has a middle name, it&amp;nbsp; will be always the third word, after title and forename), but my code is counting&amp;nbsp;double-barrelled names as two words instead of one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, with Ms Anne-Marie Beasley, my code is counting four words instead of three. As a result, my&amp;nbsp;created 'Middle_Initial' variable is showing "B" instead of being blank (as Anne-Marie is supposed to just be one word for the forename).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another example is Mr James Headey-Greaves. My countw function is counting four words instead of three (as Headey-Greaves is the surname and Headey is not a middle name), so my created 'Middle_Initial' variable is showing "H" instead of being blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please can someone help to suggest a fix to my code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final_checks;
   set testing;
   Title=scan(Name,1,1,' ');
   Forename=scan(Name,1,2,' ');
   countofwords=countw(Name); /*Issue with double-barrelled names not counting as one word*/
   if countofwords&amp;gt;3 then Middle_Initial=substr((scan(Name,3,' ')),1,1); /*Issue with double-barrelled names not counting as one word*/
   Surname=scan(Name,-1,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 00:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-double-barrel-name-as-one-word/m-p/821514#M324327</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2022-07-05T00:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to count double-barrel name as one word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-double-barrel-name-as-one-word/m-p/821516#M324328</link>
      <description>&lt;P&gt;This should correct your word counting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  full_name = 'Mr James Headey-Greaves';
  word_count = countw(full_name,,'AL');
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 01:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-double-barrel-name-as-one-word/m-p/821516#M324328</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-07-05T01:00:34Z</dc:date>
    </item>
  </channel>
</rss>

