<?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: split a full name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764975#M242282</link>
    <description>Look up SCAN() function. But how will you tell the difference between cadence and middle name? That one may require you to provide a list of possible values as it can be pretty long. FYI - if you have SAS Data Quality Studio I think it does this for you.</description>
    <pubDate>Tue, 31 Aug 2021 02:10:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-08-31T02:10:43Z</dc:date>
    <item>
      <title>split a full name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764971#M242280</link>
      <description>&lt;P&gt;I have names that are "last name, first name". Some have a middle initial and some have "Jr". The middle initial is always after the first name separated by a space and the "Jr" is always after the last name separated by a space. How can I split this in 4 different columns? fname, lname, mname, cadency&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input FullName $50.;
datalines;
Smith, John
Smith Jr, John
Smith III, John
Smith, Jane A
Smith, John J
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Aug 2021 01:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764971#M242280</guid>
      <dc:creator>axescot78</dc:creator>
      <dc:date>2021-08-31T01:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: split a full name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764974#M242281</link>
      <description>&lt;P&gt;What output do you expect for the input supplied?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 02:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764974#M242281</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-31T02:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: split a full name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764975#M242282</link>
      <description>Look up SCAN() function. But how will you tell the difference between cadence and middle name? That one may require you to provide a list of possible values as it can be pretty long. FYI - if you have SAS Data Quality Studio I think it does this for you.</description>
      <pubDate>Tue, 31 Aug 2021 02:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764975#M242282</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-31T02:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: split a full name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764980#M242284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Look up SCAN() function. But how will you tell the difference between cadence and middle name? That one may require you to provide a list of possible values as it can be pretty long. FYI - if you have SAS Data Quality Studio I think it does this for you.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks! Scan worked pretty well. This is what I came up with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
	set have;
	fname=scan(FullName, 2, ',');
	lname=scan(FullName, 1, ',') ;
	keep FullName fname lname;
run;

data want2;
	set want;
	f_count=countw(fname, ' ');
	l_count=countw(lname, ' ');
	first_name=scan(fname, 1, ' ');
	last_name=scan(lname, 1, ' ');
	if f_count=2 then middle_name=scan(fname, -1, ' ');
		else middle_name=' ';
	if l_count=2 then cadency=scan(lname, -1, ' ');
		else cadency=' ';
	keep FullName first_name middle_name last_name cadency;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Aug 2021 03:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/split-a-full-name/m-p/764980#M242284</guid>
      <dc:creator>axescot78</dc:creator>
      <dc:date>2021-08-31T03:34:52Z</dc:date>
    </item>
  </channel>
</rss>

