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:         Wed, 12 Mar 2003 17:20:57 -0500
Reply-To:     Howard_Schreier@ITA.DOC.GOV
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard_Schreier@ITA.DOC.GOV
Subject:      Re: adding prefix to each word

And to get rid of the leading space, invoke the LEFT function:

str=left(tranwrd(' '||trim(compbl(str)),' ',' new'));

On Wed, 12 Mar 2003 13:22:35 -0800, Huang, Ya <yhuang@AMYLIN.COM> wrote:

>Quentin, > >YOu are right, there is a leading space, if you want to >see that space, you need to use $char. format: > >58 data null; >59 length str $100; >60 str='one two three'; >61 str=tranwrd(' '||trim(compbl(str)),' ',' new'); >62 put str $char.; >63 put str; >64 put str= $char.; >65 run; > > newone newtwo newthree >newone newtwo newthree >str=newone newtwo newthree > >One thing I don't understand either is that why >put str= $char. dose not show the leading space. > >Ya > >-----Original Message----- >From: Quentin McMullen [mailto:Quentin_McMullen@BROWN.EDU] >Sent: Wednesday, March 12, 2003 1:06 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: adding prefix to each word > > >Ya Huang provided a nifty solution: > >> >How about tranwrd? >> > >> >19 data null; >> >20 length str $100; >> >21 str='one two three'; >> >22 str=tranwrd(' '||trim(compbl(str)),' ',' new'); >> >23 put str=; >> >24 run; >> > >> >str=newone newtwo newthree > >I would have expect so see a leading space in STR: > str= newone newtwo newthree > >Why isn't there one? > >--Quentin


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