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 (August 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 6 Aug 2004 08:44:31 -0700
Reply-To:     "Terjeson, Mark" <TERJEM@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark" <TERJEM@DSHS.WA.GOV>
Subject:      Re: trim  anumeric value
Comments: To: Jamil Ibrahim <jibrahim@IR.UMSMED.EDU>
Content-Type: text/plain

Hi Jamil,

You are very close. You've almost go it.

Of course numbers don't have blanks per se, but they do when we display them and in that process they are really getting converted to character strings for that display purpose.

Using the PUT() function is indeed the function which converts numeric to string. The PUT() function is going to require *two* arguments in order for it to know what to do. Which is why you are getting the error, you need the second format argument. The use of the TRIM() function is then going to work just as you have it, but you will also need the LEFT() function to move those leading spaces to trailing spaces.


data _null_; num_x = 123;

* the PUT STATEMENT below, when it ; * writes to the log, trims the leading ; * spaces, so you cannot tell they are ; * there, so we concatenate a couple ; * symbols on each end of the string ; * so that you can see what is really ; * in the resulting string. ; str_x = '>'||put(num_x,6.)||'<';

put 'BEFORE with leading spaces' _all_;

* since character strings justify to ; * the left and numerics justify to the ; * right then we also need the LEFT() ; * function to move the digits left and ; * then the TRIM() function can get rid ; * of trailing spaces now on the right. ; str_y = '>'||trim(left(put(num_x,6.)))||'<';

put 'AFTER without leading spaces' _all_;


Hope this is helpful, Mark Terjeson Reporting, Analysis, and Procurement Section Information Services Division Department of Social and Health Services State of Washington

-----Original Message----- From: Jamil Ibrahim [mailto:jibrahim@IR.UMSMED.EDU] Sent: Friday, August 06, 2004 8:19 AM To: SAS-L@LISTSERV.UGA.EDU Subject: trim anumeric value

Hi sas users: how do you trim a numeric var of 6. remove blanks. I tried to use put andtrim functions but they give errors trim(put(q5)) thank you


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