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 (January 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Jan 2004 13:09:47 -0500
Reply-To:     "Hornibrook, Shane" <HornibrookShane@PRAINTL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:     To: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
From:         "Hornibrook, Shane" <HornibrookShane@PRAINTL.COM>
Subject:      Re: Compressing blanks out
Comments: To: SAS-L@LISTSERV.VT.EDU
Content-Type: text/plain

Chang,

I am sure there must be a function for this, but here is a data step method;

data x; x = '1 2 3 4'; do until (length(x)= oldlength); oldlength = length(x); x = tranwrd(x,' ',' '); end; drop oldlength; run;

proc print; run;

x 1 2 3 4

Hope that helps, --Shane Shane Hornibrook Analysis Programmer PRA International 4105 Lewis & Clark Drive Charlottesville, VA 22911-5801 USA HornibrookShane@PRAIntl.com (434) 951-3433 (direct) (434) 951-3001 (fax)

-----Original Message----- From: Chang Y. Chung [mailto:chang_y_chung@HOTMAIL.COM] Sent: Tuesday, January 20, 2004 12:39 PM To: SAS-L@VM.MARIST.EDU Subject: Compressing blanks out

Hi,

There has to be a better way to compress two or more consecutive space characters into one within a character variable. Any suggestions? Thanks.

Cheers, Chang

data; ... new_str = tranwrd(tranwrd(tranwrd(tranwrd(tranwrd(old_str, " "," ")," "," ")," "," ")," "," ")," "," "); ... run;


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