<?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: Identify title, first name, middle name(s), middle name(s) initial(s) and surname in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821508#M324323</link>
    <description>&lt;P&gt;It isn't a simple as that, you need to consider several different variations of possibilities and account for them all. What happens if the name is Mr. John Smith? Or Mrs. Melissa A Adams? There are several different variations you need to account for. That being said, this is a common homework/job application question which is asked on here often. If you search you'll find examples.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2022 22:43:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-07-04T22:43:35Z</dc:date>
    <item>
      <title>Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821504#M324319</link>
      <description>&lt;P&gt;I have a variable called 'FULL_NAME'. which contains a person's full name. However, I have been asked to create the following variables:&lt;/P&gt;
&lt;P&gt;-&lt;STRONG&gt;Title&lt;/STRONG&gt; (e.g. Mr, Ms etc.)&lt;/P&gt;
&lt;P&gt;-&lt;STRONG&gt;Forename&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;-&lt;STRONG&gt;Middle_Names&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;-&lt;STRONG&gt;Full_Middle_Initial&lt;/STRONG&gt; (all of the middle name initials in full)&lt;/P&gt;
&lt;P&gt;-&lt;STRONG&gt;Reduced_Middle_Initial&lt;/STRONG&gt; (just the first initial of any middle names e.g. if Peter, Owen and Dennis are the three middle names, this variable would just contain the initial of of the first middle name: P)&lt;BR /&gt;-&lt;STRONG&gt;Surname&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example. if there is a person called "Mr James Peter Owen Dennis Coyle-Harper", what code is best to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;get the following results for the variables I have listed above? The &lt;U&gt;desired outcome&lt;/U&gt; in my example would &lt;U&gt;work&lt;/U&gt; for my &lt;U&gt;all of my 100,000 accounts&lt;/U&gt;:&lt;/P&gt;
&lt;P&gt;-Title: Mr&lt;/P&gt;
&lt;P&gt;-Forename: James&lt;/P&gt;
&lt;P&gt;-Middle_Names: Peter Owen Dennis&lt;/P&gt;
&lt;P&gt;-Full_Middle_Initial: P O D&lt;/P&gt;
&lt;P&gt;-Reduced_Middle_Initial: P&lt;BR /&gt;-Surname:&amp;nbsp;Coyle-Harper&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have currently got code that uses the scan function, but I am not sure what the best method would be to identify the middle names as there could be multiple, and the surname would just be the last word from the 'FULL_NAME' variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
        set Name_Information;
        Title=scan(FULL_NAME,1,' ');
        Forename=scan(FULL_NAME,2,' ');
        Middle_Names=???
        Full_Middle_Initial=???
        Reduced_Middle_Initial=???
        Surname=???
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>Mon, 04 Jul 2022 21:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821504#M324319</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2022-07-04T21:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821506#M324321</link>
      <description>Hint: You probably want to use COUNTW() to determine the number of words and differing number of words will have different scenario's most likely.</description>
      <pubDate>Mon, 04 Jul 2022 22:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821506#M324321</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-04T22:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821507#M324322</link>
      <description>&lt;P&gt;If someone has the code that I could use in order to get my desired outcome/provide the appropriate code where I have put question marks in the creation of the variables, that would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 22:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821507#M324322</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2022-07-04T22:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821508#M324323</link>
      <description>&lt;P&gt;It isn't a simple as that, you need to consider several different variations of possibilities and account for them all. What happens if the name is Mr. John Smith? Or Mrs. Melissa A Adams? There are several different variations you need to account for. That being said, this is a common homework/job application question which is asked on here often. If you search you'll find examples.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 22:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821508#M324323</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-04T22:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821509#M324324</link>
      <description>&lt;P&gt;Parsing full names into name components is hard. How many names do you have and are they reasonably 'clean' or not? What result quality is expected? Please bear in mind that surnames can be multiple words and names can contain titles and suffixes. Logic to deal with this will quickly get very complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Data Quality contains intelligent name parsing routines to deal with this but I doubt you have that available to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a 90% job is good enough and you haven't got millions of names then you might get lucky and do the outliers manually.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 23:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821509#M324324</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-07-04T23:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821510#M324325</link>
      <description>Hi, I've got about 100,000 accounts. From a quick glance, most only have a title, forename and surname, but some have one or a few middle names.</description>
      <pubDate>Mon, 04 Jul 2022 23:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821510#M324325</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2022-07-04T23:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Identify title, first name, middle name(s), middle name(s) initial(s) and surname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821512#M324326</link>
      <description>&lt;P&gt;I suspect you are in luck then as the cleaner and more consistent the data is the easer it is to process. I suggest you start from the left and see if you can identify all titles. Something like this should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if scan(upcase(full_name),1) in ('MR','MS','MISS') then Title = scan(full_name, 1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then check what you have left out and what is selected but shouldn't be.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 00:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-title-first-name-middle-name-s-middle-name-s-initial-s/m-p/821512#M324326</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-07-05T00:19:34Z</dc:date>
    </item>
  </channel>
</rss>

