<?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 take patient name and split into first name and last name with jrs in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581741#M13722</link>
    <description>&lt;P&gt;I would suggest going to the data source and recommending that they bring the data collection standards up to something resembling at least 1990's standards with separate first and last name fields, better would include middle name&amp;nbsp;or initial,&amp;nbsp;prefix, for those folks that insist their name is Doctor, DR, Esq., Esquire,&amp;nbsp;Senator, Representative or other professional indicator, and suffix for the Jr, II , III, IV, 'the second', and similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having dealt with some of this issue and names that looked amazing like&lt;/P&gt;
&lt;P&gt;Moon Unit Flower Child&lt;/P&gt;
&lt;P&gt;and some of the non-English constructs like&lt;/P&gt;
&lt;P&gt;Juan Garcia de Castille y Lumbago&lt;/P&gt;
&lt;P&gt;you will likely never get a single rule that works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest adding a COUNTW to get the number of space delimited items and then filtering on those that are 3 or more words for further manual&amp;nbsp;examination to verify that your code performed as needed.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2019 15:01:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-08-16T15:01:49Z</dc:date>
    <item>
      <title>How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581564#M13703</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best method for splitting patient name into first name and last name if some of the patients are a "jr"&amp;nbsp; or "IV"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The patient list does not have any commas to separate the data, it is written&lt;/P&gt;&lt;P&gt;"John Smith"&lt;/P&gt;&lt;P&gt;"John Smith Jr"&lt;/P&gt;&lt;P&gt;"Jane Smith"&lt;/P&gt;&lt;P&gt;"Jane Smith Sr"&lt;/P&gt;&lt;P&gt;"John Smith IV"&lt;/P&gt;&lt;P&gt;"John Smith III"&lt;/P&gt;&lt;P&gt;etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code&lt;/P&gt;&lt;P&gt;DATA want;&lt;BR /&gt;SET have;&lt;BR /&gt;CALL SCAN(PATIENT_NAME, -1, POSITION, LENGTH);&lt;BR /&gt;FIRST_NAME = SUBSTR(PATIENT_NAME, 1, POSITION-1);&lt;BR /&gt;LAST_NAME = SCAN(PATIENT_NAME, -1, ' ');&lt;BR /&gt;KEEP LAST_NAME FIRST_NAME DOB GENDER;&lt;BR /&gt;FORMAT FIRST_NAME LAST_NAME $100.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is this code leaves the "Jr" "Sr" "IV" in the newly created last_name variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581564#M13703</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2019-08-15T18:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581565#M13704</link>
      <description>&lt;P&gt;Do you want Jr and IV to be part of the last name?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581565#M13704</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-15T18:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581567#M13705</link>
      <description>&lt;P&gt;What would you do about a name like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jerry Van Arsdale&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Billy Bob Thornton?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In one case, Van Arsdale (words 2 and 3) are the last name; in the other case, Billy Bob (words 1 and 2) is the first name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, in your simple John Smith or Jane Smith cases, removing Jr Sr IV III is easy. The problem is much harder in general, and there's probably no solution that will work on every name in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What is the best method for splitting patient name into first name and last name if some of the patients are a "jr"&amp;nbsp; or "IV"?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    firstname=scan(patient_name,1,' ');
    secondname=scan(patient_name,2,' ');
    suffix=scan(patient_name,3,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hesitate to call this the "best" way because there are many cases where it won't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581567#M13705</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-15T19:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581568#M13706</link>
      <description>&lt;P&gt;Yes. I would like it to read&amp;nbsp;&lt;/P&gt;&lt;P&gt;first_name "John"&lt;/P&gt;&lt;P&gt;last_name "Smith Jr"&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581568#M13706</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2019-08-15T19:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581570#M13707</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp; Are you asking for this by any chance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input PATIENT_NAME $quote50.;
cards;
"John Smith"
"John Smith Jr"
"Jane Smith"
"Jane Smith Sr"
"John Smith IV"
"John Smith III"
;

data want;
set have;
firstname=substr(PATIENT_NAME,1,anyspace(PATIENT_NAME));
lastname=substr(PATIENT_NAME,anyspace(PATIENT_NAME));
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581570#M13707</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-15T19:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to take patient name and split into first name and last name with jrs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581741#M13722</link>
      <description>&lt;P&gt;I would suggest going to the data source and recommending that they bring the data collection standards up to something resembling at least 1990's standards with separate first and last name fields, better would include middle name&amp;nbsp;or initial,&amp;nbsp;prefix, for those folks that insist their name is Doctor, DR, Esq., Esquire,&amp;nbsp;Senator, Representative or other professional indicator, and suffix for the Jr, II , III, IV, 'the second', and similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having dealt with some of this issue and names that looked amazing like&lt;/P&gt;
&lt;P&gt;Moon Unit Flower Child&lt;/P&gt;
&lt;P&gt;and some of the non-English constructs like&lt;/P&gt;
&lt;P&gt;Juan Garcia de Castille y Lumbago&lt;/P&gt;
&lt;P&gt;you will likely never get a single rule that works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest adding a COUNTW to get the number of space delimited items and then filtering on those that are 3 or more words for further manual&amp;nbsp;examination to verify that your code performed as needed.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 15:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-take-patient-name-and-split-into-first-name-and-last-name/m-p/581741#M13722</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-16T15:01:49Z</dc:date>
    </item>
  </channel>
</rss>

