LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 13 Feb 2004 13:17:04 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: Prefix blanks

I was terse and thus ambiguous. I meant to say that COMPRESS will remove not only leading blanks, but also embedded blanks (that is, blanks which are internal rather than leading or trailing). As to its treatment of trailing blanks, I intended to make no comment since it was not of concern in the situation under discussion. Sorry for the confusion. .

On Fri, 13 Feb 2004 09:04:27 -0500, Don Henderson <donaldjhenderson@HOTMAIL.COM> wrote:

>Howard, > >Why do you think that compress does not eliminate leading and trailing >blanks? Consider the following: > >7 data _null_; >8 char = ' Has embedded and trailing blanks '; >9 call symput('Compressed',compress(char)); >10 call symput('notCompressed',char); >11 run; > >NOTE: DATA statement used: > real time 0.00 seconds > cpu time 0.00 seconds > > >12 %put Compressed=*&Compressed*; >Compressed=*Hasembeddedandtrailingblanks* >13 %put notCompressed=*&notCompressed*; >notCompressed=* Has embedded and trailing blanks * > >Certainly if the results of compress are assigned back to a character >variable whose length is longer that the compressed string the blanks will >be "added back." > >-don h > >----- Original Message ----- >From: "Howard Schreier" <Howard_Schreier@ITA.DOC.GOV> >Newsgroups: bit.listserv.sas-l >To: <SAS-L@LISTSERV.UGA.EDU> >Sent: Friday, February 13, 2004 8:36 AM >Subject: Re: Prefix blanks > > >> COMPRESS will remove embedded (internal, neither leading nor trailing) >> blanks. That was not specified. The LEFT function will remove leading >> blanks only. >> >> On Mon, 24 May 2004 12:12:14 +0530, Arun X Kumar <Arunk@DELHI.TCS.CO.IN> >> wrote: >> >> >Hi, >> >For problem A compress function can be used as >> >data a1; >> >set a; >> >y=compress(x,''); >> >run; >> >For problem B, apart from array(as suggested by Lars), %do loop can also >> >be used as >> > >> > >> >%macro aaa; >> >data new ; >> > set old ; >> >%do i=1 %to 200; >> > newvar&i = input (oldvar&i, 12.); >> >%end; >> >run; >> >%mend aaa; >> >%aaa >> > >> > >> > >> >Arun Kumar >> >ACDO2002 >> >Tata Consultancy Services >> >C-56, Noida Phase-2, Noida >> >Phone: +91 120 2461001(Extn-1102) >> > >> > >> > >> > >> > >> > >> >Sun Bow <sunbow4u@HOTMAIL.COM> >> >Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> >> >02/13/2004 11:20 AM >> >Please respond to Sun Bow >> > >> > >> > To: SAS-L@LISTSERV.UGA.EDU >> > cc: >> > Subject: Prefix blanks >> > >> > >> >Hi, >> >Problem A: >> > >> >In one of my dataset the values of variables have blanks in prefix ie its >> >like ' 16 (say 10 balnks before numbers). Is there a way to >> >remove them? >> > >> >Problem B: >> >The same dataset has more than 200 variables. I used >> >newvar1 = input (oldvar1, 12.); >> >....... >> >newvar200 = input (oldvar200, 12.); >> >to convert all these character to numeric. I am sure there is a much >> >efficient way to do this but I am quite new to SAS. >> > >> >Will appreciate help. >> > >> >Sunbow >>


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