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>
From: "Hornibrook, Shane" <HornibrookShane@PRAINTL.COM>
Subject: Re: Compressing blanks out
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;
|