Date: Tue, 8 Feb 2011 16:48:02 -0500
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Strip Function And Leading and Trailing Tab Chars
On Tue, 8 Feb 2011 16:22:21 -0500, Chang Chung <chang_y_chung@HOTMAIL.COM>
wrote:
>Below is my
>test code. In terms of real time, I get wildly different results each time
>I run it, despite of the sasfile'ing. But I noticed that the cpu time is
>always about twice as longer for data step toby than chang.
...
Hi, Toby,
well... please forget about my previous posting. I've made a mistake of
generating all blank test data. Once I fixed it, your two prxchange call
solution ran much faster consistently... below is the fixed code.
Cheers,
Chang
%let seed=12346789;
data one;
length s $200;
do i = 1 to 1e6;
do j = 1 to 200;
if ranuni(&seed) < 0.15 then substr(s,j,1) = " ";
else substr(s,j,1) = "x";
end;
output;
end;
keep s;
run;
sasfile work.one.data open;
data chang;
set one;
s2 = prxchange('s/^\s+|\s+$//o', -1, s);
keep s s2;
run;
data toby;
set one;
s3 = prxchange('s/^\s+//o', 1, s);
s3 = prxchange('s/\s+$//o', 1, s3);
keep s s3;
run;
sasfile work.one.data close;
proc compare data=toby compare=chang(rename=(s2=s3));
run;
/* on log
NOTE: No unequal values were found. All values compared are exactly equal.
*/
|