<?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: first name and last name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885025#M349680</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
name='George W. Bush';

call scan(name,-1,p,l,' ');
firstname=substr(name,1,p-1);
lastname=substr(name,p);
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jul 2023 12:03:41 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-07-17T12:03:41Z</dc:date>
    <item>
      <title>first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885012#M349675</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;name='George W. Bush'&lt;/P&gt;
&lt;P&gt;required output:&lt;/P&gt;
&lt;P&gt;Fname&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lname&lt;/P&gt;
&lt;P&gt;George W.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bush&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 10:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885012#M349675</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-07-17T10:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885023#M349678</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;; have a look here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Separate-Full-Name-to-FirstName-and-LastName/td-p/458664" target="_blank"&gt;Separate Full Name to FirstName and LastName - SAS Support Communities&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(And next time please look for existing solutions before asking already answered questions.)&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;Markus&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 11:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885023#M349678</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2023-07-17T11:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885024#M349679</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data output;
   set YourDataset; /* Replace "YourDataset" with the name of your actual dataset */

   Fname = scan(full_name, 1); /* Assuming the full name is stored in a variable called "full_name" */
   Lname = scan(full_name, -1); /* Extracts the last word in the full name */

   /* Output the formatted names */
   put "Fname: " Fname;
   put "Lname: " Lname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In this code, you need to replace "YourDataset" with the actual name of your dataset containing the full names. The &lt;CODE&gt;SCAN&lt;/CODE&gt; function is used to extract the first name (&lt;CODE&gt;Fname&lt;/CODE&gt;) and last name (&lt;CODE&gt;Lname&lt;/CODE&gt;) from the variable &lt;CODE&gt;full_name&lt;/CODE&gt;. The &lt;CODE&gt;-1&lt;/CODE&gt; as the second argument of &lt;CODE&gt;SCAN&lt;/CODE&gt; tells SAS to extract the last word in the string. Finally, the &lt;CODE&gt;put&lt;/CODE&gt; statements are used to display the formatted output in the SAS log.&lt;/P&gt;
&lt;P&gt;Make sure to adjust the code according to your specific dataset and variable names.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 12:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885024#M349679</guid>
      <dc:creator>himself</dc:creator>
      <dc:date>2023-07-17T12:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885025#M349680</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
name='George W. Bush';

call scan(name,-1,p,l,' ');
firstname=substr(name,1,p-1);
lastname=substr(name,p);
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2023 12:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885025#M349680</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-17T12:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: first name and last name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885082#M349703</link>
      <description>&lt;P&gt;Now, what do you expect for a "first" and "last" name from these names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sun Flower Moon Child&lt;/P&gt;
&lt;P&gt;John Richard II Van Opdorp&lt;/P&gt;
&lt;P&gt;Maria Garcia Y Mendoza&lt;/P&gt;
&lt;P&gt;Smith, John David Junior&lt;/P&gt;
&lt;P&gt;Junior Childs Junior&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are rules for parsing names that are cultural and almost any simple one or two line programming solution won't "work" for all of them and may not work for large numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the question is "what are the first two words out of this list of 3 words" that is one thing.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 14:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-name-and-last-name/m-p/885082#M349703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-17T14:38:31Z</dc:date>
    </item>
  </channel>
</rss>

