LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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)
Comments: To: Aaron Reid <aaronreid@EUROPE.COM>


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

Back to: Top of message | Previous page | Main SAS-L page