Date: Tue, 25 Aug 2009 22:22:53 +0530
Reply-To: Cherish K <c4cherish@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Cherish K <c4cherish@GMAIL.COM>
Subject: Re: Compare words
Content-Type: text/plain; charset=ISO-8859-1
COMPGED is the function used in SAS 9 which uses generalized edit distance
On Tue, Aug 25, 2009 at 10:20 PM, Cherish K <email@example.com> wrote:
> I doubt if there is any function which can check for all the words. Here is
> a code below which will check all the words in the string1 and compare it
> with string2.
> data chk;
> String1 = 'University of Georgia';
> String2 = 'Univ of Georgia';
> data chk1;
> set chk;
> j = 1;
> l = length(trim(string1));
> tot_num_words = 0;
> tot_words_match = 0;
> do i = 1 to l;
> if substr(String1,i,1) = " " or i = l then do;
> if index(string2,substr(string1,j,i-j)) > 0 then tot_words_match+1;
> j = i+1;
> drop i j l;
> Note: If you check string2 with string1, the match will be 3.
> Alternatively there are some distance algorithms which will give the
> closeness of string1 with string2 and vice versa which am not exactly aware
> of. Somebody else can throw light on that.
> On Tue, Aug 25, 2009 at 8:59 PM, Abc Unha <firstname.lastname@example.org> wrote:
>> Is there anyway to compare words in SAS?
>> For e.g
>> 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