<?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 Seperate names in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62227#M17698</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a situation,where i have a variable NAME&lt;BR /&gt;
eg:&lt;BR /&gt;
NAME&lt;BR /&gt;
----------&lt;BR /&gt;
JOHN C MAT,MD&lt;BR /&gt;
SARA ATIO,MD&lt;BR /&gt;
&lt;BR /&gt;
I would like to seperate this name as Fname,MIDname,Lname&lt;BR /&gt;
so my output look like&lt;BR /&gt;
Fname    MIDname           Fname&lt;BR /&gt;
---------------------------------------------------&lt;BR /&gt;
JOHN       C                    MAT,MD&lt;BR /&gt;
SARA                             ATIO,MD&lt;BR /&gt;
&lt;BR /&gt;
Please let me know,if you have a solution for this.&lt;BR /&gt;
&lt;BR /&gt;
thanks,&lt;BR /&gt;
Ren</description>
    <pubDate>Thu, 25 Feb 2010 22:01:25 GMT</pubDate>
    <dc:creator>ren2010</dc:creator>
    <dc:date>2010-02-25T22:01:25Z</dc:date>
    <item>
      <title>Seperate names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62227#M17698</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a situation,where i have a variable NAME&lt;BR /&gt;
eg:&lt;BR /&gt;
NAME&lt;BR /&gt;
----------&lt;BR /&gt;
JOHN C MAT,MD&lt;BR /&gt;
SARA ATIO,MD&lt;BR /&gt;
&lt;BR /&gt;
I would like to seperate this name as Fname,MIDname,Lname&lt;BR /&gt;
so my output look like&lt;BR /&gt;
Fname    MIDname           Fname&lt;BR /&gt;
---------------------------------------------------&lt;BR /&gt;
JOHN       C                    MAT,MD&lt;BR /&gt;
SARA                             ATIO,MD&lt;BR /&gt;
&lt;BR /&gt;
Please let me know,if you have a solution for this.&lt;BR /&gt;
&lt;BR /&gt;
thanks,&lt;BR /&gt;
Ren</description>
      <pubDate>Thu, 25 Feb 2010 22:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62227#M17698</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-02-25T22:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Seperate names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62228#M17699</link>
      <description>Hi:&lt;BR /&gt;
  There are a number of character string functions -- the simple ones, like SCAN and SUBSTRING and FIND and INDEX and the more complex ones, like the Perl Regular Expression which would allow you to break up a string into chunks.&lt;BR /&gt;
 &lt;BR /&gt;
  There's a simple example at the end of this post. If you don't have regular names (maybe 1 middle name, maybe 2 middle names, possible space before MD, maybe not, maybe 2 credentials), then you may want to go down the Perl Regular Expression road. There have been many postings in the Forum on splitting up text strings.&lt;BR /&gt;
 &lt;BR /&gt;
  As you can see from the log results of this program (with the Big Bird, Yellow) results, the SCAN approach only lends itself to very regular data.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data break_it_up;&lt;BR /&gt;
  length name $30;&lt;BR /&gt;
  infile datalines dsd;&lt;BR /&gt;
  input name $;&lt;BR /&gt;
  first = scan(name,1,' ');&lt;BR /&gt;
  middle = scan(name,2,' ');&lt;BR /&gt;
  last = scan(name,3,' ');&lt;BR /&gt;
  suffix = scan(name,4,', ');&lt;BR /&gt;
  if last = ' ' then do;&lt;BR /&gt;
     ** takes care of no middle name;&lt;BR /&gt;
     last = middle;&lt;BR /&gt;
	 middle = ' ';&lt;BR /&gt;
  end;&lt;BR /&gt;
  put "*************************************************";&lt;BR /&gt;
  put (_all_) (=);&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
"Kermit The Frog,Esq."&lt;BR /&gt;
"Oscar The Grouch, GC"&lt;BR /&gt;
"Miss Piggy"&lt;BR /&gt;
"Big Bird, Yellow"&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
                         &lt;BR /&gt;
LOG RESULTS from PUT statements:&lt;BR /&gt;
*************************************************&lt;BR /&gt;
name=Kermit The Frog,Esq. first=Kermit middle=The last=Frog,Esq. suffix=Esq.&lt;BR /&gt;
*************************************************&lt;BR /&gt;
name=Oscar The Grouch, GC first=Oscar middle=The last=Grouch, suffix=GC&lt;BR /&gt;
*************************************************&lt;BR /&gt;
name=Miss Piggy first=Miss middle=  last=Piggy suffix=&lt;BR /&gt;
*************************************************&lt;BR /&gt;
name=Big Bird, Yellow first=Big middle=Bird, last=Yellow suffix=&lt;BR /&gt;
NOTE: The data set WORK.BREAK_IT_UP has 4 observations and 5 variables.&lt;BR /&gt;
           &lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 25 Feb 2010 22:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62228#M17699</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-02-25T22:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Seperate names</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62229#M17700</link>
      <description>Thanks Cynthia</description>
      <pubDate>Thu, 25 Feb 2010 22:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Seperate-names/m-p/62229#M17700</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-02-25T22:50:15Z</dc:date>
    </item>
  </channel>
</rss>

