Date: Fri, 14 Mar 2003 14:14:53 -0500
Reply-To: Ira Roberts <ir10@MAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ira Roberts <ir10@MAIL.COM>
Subject: Re: concatenate numeric range and the name (partial solution)
Aaron,
you may want to try the following:
data test;
whogets='Bob Helen 10-18 Kathy 24 Glenn Tracy 16-18 Peter Tom';
nwords=(compress(whogets) ne ' ') * (length(left(compbl(whogets)))-
length(compress(whogets))+1); *<** BTW, this is proprietary to SAS-L;
do i=1 to (nwords-1);
word1=scan(whogets,i,' ');
word2=scan(whogets,i+1,' ');
if not verify(substr(word2,1,1),'0123456789')
then word3=trim(left(word1))||trim(left(word2));
else word3=' ';
output;
end;
run;
Your word3 will have only the combined names||ranges.
Regards,
Ira
PS. I bet there is a better solution, but this should work anyway
On Fri, 14 Mar 2003 13:33:16 -0500, Aaron Reid <aaronreid@EUROPE.COM> wrote:
>People:
>
>I have the following string:
> whogets='Bob Helen 10-18 Kathy 24 Glenn Tracy 16-18 Peter Tom';
>
>is there a way to create the following:
> whogot='Bob Helen10-18 Kathy24 Glenn Tracy16-18 Peter Tom';
>
>Namely, when a number (or a range) follows the name, I have to concatenate
>them together, otherwise they should remain as they are.
>
>Thanks!
>Aaron
|