Date: Tue, 25 Aug 2009 13:42:26 -0400
Reply-To: Paul Dorfman <sashole@BELLSOUTH.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <sashole@BELLSOUTH.NET>
Subject: Re: Compare words
IndexW is designed for the purpose and is perhaps more suitable here (and
faster) than incremental substringing. Consider:
data a ;
infile cards dlm = "," ;
input (s1 s2) (:$32.) ;
one two three, four five six seven
one two three, three four five
three four, ten four three
seven eleven, eleven seven gazillion
is two plus one three, or is three plus one four
in sas base has most mass, but all its mass is not base sas
data b ;
set a ;
do _i = 1 by 1 ;
_s = put (scan (s1, _i, ""), $32.) ;
if _s = "" then leave ;
count = sum (count, ^^indexw (s2, strip (_s))) ;
When I exploded the input data set to 6 million obs, it took SAS 9.2 to
run the (_null_ed) step B in about 12 seconds under WXPro on a V9.2 garden
variety office desktop. I had expected performance to be worse.
On Tue, 25 Aug 2009 11:29:19 -0400, Abc Unha <abcunha@YAHOO.COM> wrote:
>Is there anyway to compare words in SAS?
>String1 = 'University of Georgia'
>String2 = 'Univ of Georgia'
>Here I would like to compare String1 and String2. As you can see there are
>two words matching therefore In results i would like to have '2'.
>Is there any function that can return number of words matched between two