Date: Wed, 10 Aug 2005 07:26:12 -0700
Reply-To: Wendy <XieWeiTing@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Wendy <XieWeiTing@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: How to extract the last name,
In-Reply-To: <7d11935705081006585d1445cd@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
data test1;
set test;
name=trim(left(name));
if index(name,",") ne 0 then
do;
first =scan(name,3," "","".");
middle=scan(name,2," "","".");
last=scan(name,1," "","".");
if first="" and middle ne "" then
do ;
first=middle; middle="";
end;
end;
else
do;
first =scan(name,1," "".");
middle=scan(name,2," "".");
last=scan(name,3," "".");
if last="" and middle ne "" then
do ;
last=middle; middle="";
end;
end;
run;
|