<?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: Separating first name and last name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233386#M42605</link>
    <description>Thank you all for your replies. I was asked this question in one of my interviews. I answered the same but the interviewer was not convinced and then I thought there may be a way to do this.</description>
    <pubDate>Fri, 06 Nov 2015 06:18:37 GMT</pubDate>
    <dc:creator>gurpreetkaur</dc:creator>
    <dc:date>2015-11-06T06:18:37Z</dc:date>
    <item>
      <title>Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233199#M42573</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to separate first name and last name which do not have any delimiter specified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sample;&lt;BR /&gt; input name : $20.;&lt;BR /&gt; datalines;&lt;BR /&gt; gurpreetkaur&lt;BR /&gt; anujmadan&lt;BR /&gt; dhirajdhingra&lt;BR /&gt; mehakbhasin&lt;BR /&gt; sahibakhurana&lt;BR /&gt; ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need a dataset from the above dataset with ouput as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" class="xl63" style="height: 14.4pt; width: 48pt;"&gt;first name&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;last name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.4pt; border-top: none;"&gt;gurpreet&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;kaur&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.4pt; border-top: none;"&gt;anuj&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;madan&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.4pt; border-top: none;"&gt;dhiraj&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;dhingra&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.4pt; border-top: none;"&gt;mehak&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;bhasin&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.4pt; border-top: none;"&gt;sahiba&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;khurana&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how should I get the above data set??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks !!&lt;/P&gt;
&lt;P&gt;Gurpreet Kaur&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 03:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233199#M42573</guid>
      <dc:creator>gurpreetkaur</dc:creator>
      <dc:date>2015-11-05T03:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233203#M42574</link>
      <description>&lt;P&gt;If there is no rule or pattern you can describe that identifies where the word boundaries are then there is no way to program it in SAS or any other computer language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only way I suspect this would work is if your software had access to an appropriate database of surnames and first names and you were able to do name matches. This is definitely not available in Base SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 04:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233203#M42574</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-11-05T04:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233226#M42579</link>
      <description>I agree with saskiwi on this. We need a pattern or some information which helps differentiate the surname and last name</description>
      <pubDate>Thu, 05 Nov 2015 11:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233226#M42579</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-11-05T11:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233234#M42582</link>
      <description>&lt;P&gt;Hi mate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this small table you can use multiple IFs and substr function to separate what you need.&lt;/P&gt;
&lt;P&gt;But if your table is very large and there is no patterns, then you need a new way to get this table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with Kiwi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for this small table you can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro name(name,pos,len,pos1,len1);&lt;BR /&gt; &lt;BR /&gt; data want_&amp;amp;name(where=(last_name ne ""));&lt;BR /&gt; set sample;&lt;BR /&gt; if substr(name,1,1) = "&amp;amp;name." then do;&lt;BR /&gt; last_name = substr(name,&amp;amp;pos. ,&amp;amp;len.);&lt;BR /&gt; first_name = substr(name,&amp;amp;pos1.,&amp;amp;len1.);&lt;BR /&gt; end;&lt;BR /&gt; run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%name(g,9,6 ,1,8);&lt;BR /&gt;%name(a,5,6 ,1,4);&lt;BR /&gt;%name(d,7,10,1,9);&lt;BR /&gt;%name(m,6,10,1,5);&lt;BR /&gt;%name(s,7,10,1,6);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;And then append.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 13:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233234#M42582</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-05T13:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233238#M42584</link>
      <description>&lt;P&gt;Agree with everyone above. Even something as simple as capital letter for each first and last name would help. Anything to determine the start position of each name element (including middle initials if there are any).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you altered the data in any way to make them all lowercase, then maybe you have the information you need, otherwise, you will need to request a new file with the appropriate delimiters.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 14:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233238#M42584</guid>
      <dc:creator>MaikH_Schutze</dc:creator>
      <dc:date>2015-11-05T14:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233386#M42605</link>
      <description>Thank you all for your replies. I was asked this question in one of my interviews. I answered the same but the interviewer was not convinced and then I thought there may be a way to do this.</description>
      <pubDate>Fri, 06 Nov 2015 06:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233386#M42605</guid>
      <dc:creator>gurpreetkaur</dc:creator>
      <dc:date>2015-11-06T06:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Separating first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233446#M42629</link>
      <description>&lt;P&gt;It is possible that what you presented was not exactly what the interviewer asked or the data example you provided had some difference.&lt;/P&gt;
&lt;P&gt;A very minor change such as the name parts starting with a capital letter would make it possible.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 15:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-first-name-and-last-name/m-p/233446#M42629</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-11-06T15:36:00Z</dc:date>
    </item>
  </channel>
</rss>

