<?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: extracting first and last name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415585#M280154</link>
    <description>&lt;P&gt;Something along these lines might be enough to get you started.&amp;nbsp; This code could fail if a name begins with "OD" and for other reasons.&amp;nbsp; You might want to deal with the degrees a bit differently.&lt;/P&gt;
&lt;PRE&gt;data x(drop=n);&lt;BR /&gt; input n $ 1-40;&lt;BR /&gt; name = n;&lt;BR /&gt; n = tranwrd(n, ' MD', ' ');&lt;BR /&gt; n = tranwrd(n, ' DDS', ' ');&lt;BR /&gt; n = tranwrd(n, ' OD', ' ');&lt;BR /&gt; if find(n, ',') then last = scan(n, 1, ',');&lt;BR /&gt; else last = scan(n, 1, ' ');&lt;BR /&gt; if find(n, ',') then first = scan(n, 2, ',');&lt;BR /&gt; else first = scan(n, 2, ' ');&lt;BR /&gt; first = scan(first, 1);&lt;BR /&gt; datalines;&lt;BR /&gt;STEVENS MD,STEVE ROBERT&lt;BR /&gt;WAINWRIGHT MD,LISA S N&lt;BR /&gt;DUDLEY DDS,WARREN&lt;BR /&gt;KARZ MD REX H&lt;BR /&gt;BROWN,RED&lt;BR /&gt;DE LA HOYA OD,RACSO B&lt;BR /&gt;;&lt;BR /&gt;proc print; run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;            Obs    name                       last          first

              1     STEVENS MD,STEVE ROBERT    STEVENS       STEVE 
              2     WAINWRIGHT MD,LISA S N     WAINWRIGHT    LISA  
              3     DUDLEY DDS,WARREN          DUDLEY        WARREN
              4     KARZ MD REX H              KARZ          REX   
              5     BROWN,RED                  BROWN         RED   
              6     DE LA HOYA OD,RACSO B      DE LA HOYA    RACSO 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Nov 2017 17:51:21 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2017-11-22T17:51:21Z</dc:date>
    <item>
      <title>extracting first and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415568#M280152</link>
      <description>&lt;TABLE width="288"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="288"&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;STEVENS MD,STEVE ROBERT&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;WAINWRIGHT MD,LISA S N&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;DUDLEY DDS,WARREN&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;KARZ MD REX H&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;BROWN,RED&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;DE LA HOYA OD,RACSO B&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need to extract first and last name from a provider list.&amp;nbsp;&amp;nbsp;&amp;nbsp; Most records contain a title (MD, OD, PT, CRNP, etc) but not all.&lt;/P&gt;
&lt;P&gt;The first name on the above list is the most frequent format on the list but there are many other formats - as shown by&lt;/P&gt;
&lt;P&gt;records 2-6 above.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Using 9.4&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 16:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415568#M280152</guid>
      <dc:creator>uabcms</dc:creator>
      <dc:date>2017-11-22T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: extracting first and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415570#M280153</link>
      <description>&lt;P&gt;So what's the rules you've developed so far?&lt;/P&gt;
&lt;P&gt;Can you show what you'd expect as output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think SCAN will get you most of the way there, but there are some formats that will be problematic for sure.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 16:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415570#M280153</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-22T16:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: extracting first and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415585#M280154</link>
      <description>&lt;P&gt;Something along these lines might be enough to get you started.&amp;nbsp; This code could fail if a name begins with "OD" and for other reasons.&amp;nbsp; You might want to deal with the degrees a bit differently.&lt;/P&gt;
&lt;PRE&gt;data x(drop=n);&lt;BR /&gt; input n $ 1-40;&lt;BR /&gt; name = n;&lt;BR /&gt; n = tranwrd(n, ' MD', ' ');&lt;BR /&gt; n = tranwrd(n, ' DDS', ' ');&lt;BR /&gt; n = tranwrd(n, ' OD', ' ');&lt;BR /&gt; if find(n, ',') then last = scan(n, 1, ',');&lt;BR /&gt; else last = scan(n, 1, ' ');&lt;BR /&gt; if find(n, ',') then first = scan(n, 2, ',');&lt;BR /&gt; else first = scan(n, 2, ' ');&lt;BR /&gt; first = scan(first, 1);&lt;BR /&gt; datalines;&lt;BR /&gt;STEVENS MD,STEVE ROBERT&lt;BR /&gt;WAINWRIGHT MD,LISA S N&lt;BR /&gt;DUDLEY DDS,WARREN&lt;BR /&gt;KARZ MD REX H&lt;BR /&gt;BROWN,RED&lt;BR /&gt;DE LA HOYA OD,RACSO B&lt;BR /&gt;;&lt;BR /&gt;proc print; run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;            Obs    name                       last          first

              1     STEVENS MD,STEVE ROBERT    STEVENS       STEVE 
              2     WAINWRIGHT MD,LISA S N     WAINWRIGHT    LISA  
              3     DUDLEY DDS,WARREN          DUDLEY        WARREN
              4     KARZ MD REX H              KARZ          REX   
              5     BROWN,RED                  BROWN         RED   
              6     DE LA HOYA OD,RACSO B      DE LA HOYA    RACSO 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Nov 2017 17:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/415585#M280154</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-11-22T17:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: extracting first and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/416675#M280156</link>
      <description>&lt;P&gt;will give this a try.&amp;nbsp; Thanks very much.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 13:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-first-and-last-name/m-p/416675#M280156</guid>
      <dc:creator>uabcms</dc:creator>
      <dc:date>2017-11-28T13:19:05Z</dc:date>
    </item>
  </channel>
</rss>

