<?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: Extract Title and Name from string in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611622#M18232</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all3; 
length title $ 12 fullname name $ 40;
set  all;
fullname=compress(fullname,'.');
if fullname=: 'Mr' then do; 
	title=scan(fullname,1)||'.'; 
	name=substr(fullname,anyspace(fullname)+1);
end;
else IF fullname=: 'Miss' 	THEN do;
	Title=SCAN(Fullname,1)||'.';
	name=substr(fullname,anyspace(fullname)+1);
end;
else IF fullname=: 'Dr' 	THEN do;
	Title=SCAN(Fullname,1)||'.';
	name=substr(fullname,anyspace(fullname)+1);
end;
else name=fullname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This method will fail for other abbreviations before the person's name, such as Msgr.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2019 15:58:50 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-12-13T15:58:50Z</dc:date>
    <item>
      <title>Extract Title and Name from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611607#M18227</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I want to extract people's first name where the full name starts with one of the following&lt;/P&gt;
&lt;P&gt;Mr,&lt;/P&gt;
&lt;P&gt;Mr.,&lt;/P&gt;
&lt;P&gt;Mrs,&lt;/P&gt;
&lt;P&gt;Mrs.,&lt;/P&gt;
&lt;P&gt;Dr,&lt;/P&gt;
&lt;P&gt;Dr.&lt;/P&gt;
&lt;P&gt;Please note that some name doesn't start with their Title. So far I was able to work with the Title part. But I need help with the name part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA All;
INPUT Fullname $40.;
CARDS;
Mr. Simon Hill
Mr ABBY ANTAL
Tom Kewen
Miss Ann Sharp
Miss. Carla Newman
Mrs SYLVIA TUYTEL
Aleya Khan
Mrs.&amp;nbsp;Melissa Ward
Dr. Cobi Sharpe;
RUN;

DATA SShuffle.All3; 
LENGTH Title Fullname2 $ 40.;
SET  SShuffle.All2;
IF fullname=: 'Mr.' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Mr '     THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Mrs.' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Mrs ' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Miss.' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Miss ' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Dr.' 	THEN Title=SCAN(Fullname,1)||'.';
IF fullname=: 'Dr ' 	THEN Title=SCAN(Fullname,1)||'.';

RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Title&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;BR /&gt;Mr.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Simon Hill&lt;/P&gt;
&lt;P&gt;Mr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ABBY ANTAL&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Tom Kewen&lt;/P&gt;
&lt;P&gt;Miss&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Ann Sharp&lt;/P&gt;
&lt;P&gt;Miss.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carla Newman&lt;/P&gt;
&lt;P&gt;Mrs&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SYLVIA TUYTEL&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Aleya Khan&lt;/P&gt;
&lt;P&gt;Mrs.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Melissa Ward&lt;/P&gt;
&lt;P&gt;Dr.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cobi Sharpe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone please help.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611607#M18227</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-12-13T15:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude specific words from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611611#M18228</link>
      <description>&lt;P&gt;Explain further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the names ALWAYS begin with one of these abbreviations? Or do some names begin with the person's name and no abbreviation? Do some names begin with a different abbreviation not on your list, what should we do then?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give us some rules (in words) that we can turn into code.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611611#M18228</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-13T15:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude specific words from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611615#M18231</link>
      <description>Hi PaigeMillar, Yes some name doesn't start with Title. I modified my post. Would you please read again. Thanks.</description>
      <pubDate>Fri, 13 Dec 2019 15:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611615#M18231</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-12-13T15:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Title and Name from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611622#M18232</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all3; 
length title $ 12 fullname name $ 40;
set  all;
fullname=compress(fullname,'.');
if fullname=: 'Mr' then do; 
	title=scan(fullname,1)||'.'; 
	name=substr(fullname,anyspace(fullname)+1);
end;
else IF fullname=: 'Miss' 	THEN do;
	Title=SCAN(Fullname,1)||'.';
	name=substr(fullname,anyspace(fullname)+1);
end;
else IF fullname=: 'Dr' 	THEN do;
	Title=SCAN(Fullname,1)||'.';
	name=substr(fullname,anyspace(fullname)+1);
end;
else name=fullname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This method will fail for other abbreviations before the person's name, such as Msgr.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611622#M18232</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-13T15:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude specific words from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611626#M18234</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA All;
INPUT Fullname $40.;
CARDS;
Mr. Simon Hill
Mr ABBY ANTAL
Tom Kewen
Miss Ann Sharp
Miss. Carla Newman
Mrs SYLVIA TUYTEL
Aleya Khan
Mrs. Melissa Ward
Dr. Cobi Sharpe
;
RUN;

data want;
set all;
length title $5 name $50;
IF fullname in : ('Mr.','Mr','Mrs.','Mrs ','Miss.', 'Miss ','Dr.','Dr ') 	THEN do;
Title=SCAN(Fullname,1)||'.';
name=substr(fullname,anyspace(fullname)+1);
end;
else name=Fullname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 16:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611626#M18234</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-13T16:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude specific words from string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611637#M18235</link>
      <description>&lt;P&gt;Adding&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My solution but not the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;will fail if someone's name is not preceded by an abbreviation, and the person's name begins with Miss, such as Missy Taylor. I'm sure there is a simple adjustment to my code that will fix this, but not needed as there is a solution that doesn't have this problem.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 16:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-Title-and-Name-from-string/m-p/611637#M18235</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-13T16:22:15Z</dc:date>
    </item>
  </channel>
</rss>

