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 (February 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 8 Feb 2011 16:22:21 -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
Comments: To: Toby Dunn <tobydunn@HOTMAIL.COM>

On Tue, 8 Feb 2011 20:20:30 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote: ... >I'll preface this with much depends on ones data if you are looking to eek the last ounce of speed and/or efficiency. >However, the two RegEx solution is by in large the best all around solution. ... hi, toby, Thanks for the Friedl reference. I get that the alternation (|) kills the prx optimization. But this matters only when the overhead of making the prxchange() function call is negligible compared to the savings you get from prx optimization. I am not so sure if this is the case. 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. Cheers, Chang

%let seed=1234;

data one; length s $200; do i = 1 to 1e6; do j = 1 to 200; if ranuni(&seed) < 0.05 then substr(s,j,1) = " "; end; output; end; 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. */


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