<?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: Need Correction on finding the first name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439302#M109613</link>
    <description>&lt;P&gt;Very similar to what Astounding just said, but I'd add the space character into the scan delimiter listing as well just to confirm that the space doesn't offset our numbers. Here's my thought process to help you understand the code in another way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Last_Name = SCAN(name, 1, ",");
First_Middle = SCAN(name, 2, ", ");
First_Name = SUBSTR(First_Middle, 1, LENGTH(First_Middle)-2);
Middle_Init = SUBSTR(First_Middle, LENGTH(First_Middle)-1, 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last name&amp;nbsp;is easiest to grab; you've already got that. Then you can take the cluster of First and Middle initials together. First name is the substring of everything EXCEPT those last two characters, middle initials are ONLY the last two characters. (These assignments should also be inside a data step, to be clear)&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2018 14:53:39 GMT</pubDate>
    <dc:creator>GinaRepole</dc:creator>
    <dc:date>2018-02-22T14:53:39Z</dc:date>
    <item>
      <title>Need Correction on finding the first name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439274#M109600</link>
      <description>&lt;P&gt;HI all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a data sets which has names like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Nichols, KregFI&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its in the form&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"lastname,(space)firstnamemiddlename"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;accept&amp;nbsp;&lt;/SPAN&gt;my o/p to be like this :&lt;/P&gt;&lt;P&gt;firstname=kerg&lt;/P&gt;&lt;P&gt;middlename=Fl&lt;/P&gt;&lt;P&gt;lastname=Nichols&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code for that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;str='Nichols, KregFI';&amp;nbsp; &amp;nbsp;/*** String **/&lt;/P&gt;&lt;P&gt;a=index(str,",")+2;&amp;nbsp; &amp;nbsp; &amp;nbsp;/** for finding the position of first Name **/&lt;/P&gt;&lt;P&gt;first_name=substr(scan(str,2,","),1,a-1);&amp;nbsp; &amp;nbsp;/** for first name only**/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But ,I am getting o/p :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;s.no&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; str&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;first_name&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Nichols, KregFI&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;KregFI&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please correct and&amp;nbsp;&lt;SPAN&gt;assist&amp;nbsp;&lt;/SPAN&gt;me for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 14:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439274#M109600</guid>
      <dc:creator>sumitbe139</dc:creator>
      <dc:date>2018-02-22T14:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need Correction on finding the first name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439282#M109606</link>
      <description>What is the rule defining the split between the first name and middle name? &lt;BR /&gt;&lt;BR /&gt;Is the middle name a two letter abbreviation? &lt;BR /&gt;Is the middle name always going to begin with the first capital letter after the first name starts?&lt;BR /&gt;&lt;BR /&gt;Either one is possible to correct, but if the data isn't consistent with either of these styles I'm not sure it's possible (given there is no separating character).</description>
      <pubDate>Thu, 22 Feb 2018 14:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439282#M109606</guid>
      <dc:creator>GinaRepole</dc:creator>
      <dc:date>2018-02-22T14:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need Correction on finding the first name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439290#M109607</link>
      <description>&lt;P&gt;It's probably easier to start this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;last_name = scan(str, 1, ',');&lt;/P&gt;
&lt;P&gt;first_name = scan(str, 2, ',');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point, FIRST_NAME still has the initials at the end.&amp;nbsp; But you should be able to find a way to split them off into a separate variable, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;middle_name = substr(first_name, length(first_name)-1);&lt;/P&gt;
&lt;P&gt;first_name = substr(first_name, 1, length(first_name)-2);&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 14:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439290#M109607</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-22T14:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need Correction on finding the first name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439293#M109609</link>
      <description>thank you for your response,&lt;BR /&gt;&lt;BR /&gt;the first name &amp;amp; middle name has no split in between.&lt;BR /&gt;&lt;BR /&gt;yes, the middle name is two letter abbreviation.&lt;BR /&gt;&lt;BR /&gt;yes, its start with the first capital letter as the first name ends.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Feb 2018 14:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439293#M109609</guid>
      <dc:creator>sumitbe139</dc:creator>
      <dc:date>2018-02-22T14:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need Correction on finding the first name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439302#M109613</link>
      <description>&lt;P&gt;Very similar to what Astounding just said, but I'd add the space character into the scan delimiter listing as well just to confirm that the space doesn't offset our numbers. Here's my thought process to help you understand the code in another way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Last_Name = SCAN(name, 1, ",");
First_Middle = SCAN(name, 2, ", ");
First_Name = SUBSTR(First_Middle, 1, LENGTH(First_Middle)-2);
Middle_Init = SUBSTR(First_Middle, LENGTH(First_Middle)-1, 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last name&amp;nbsp;is easiest to grab; you've already got that. Then you can take the cluster of First and Middle initials together. First name is the substring of everything EXCEPT those last two characters, middle initials are ONLY the last two characters. (These assignments should also be inside a data step, to be clear)&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 14:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Correction-on-finding-the-first-name/m-p/439302#M109613</guid>
      <dc:creator>GinaRepole</dc:creator>
      <dc:date>2018-02-22T14:53:39Z</dc:date>
    </item>
  </channel>
</rss>

