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 (August 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: Abc Unha <abcunha@yahoo.com>
In-Reply-To:  <d277ae4c0908250950v431efc74k337fe193eff35f8d@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

COMPGED is the function used in SAS 9 which uses generalized edit distance algorithm.

On Tue, Aug 25, 2009 at 10:20 PM, Cherish K <c4cherish@gmail.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'; > output; > run; > > 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; > tot_num_words+1; > if index(string2,substr(string1,j,i-j)) > 0 then tot_words_match+1; > j = i+1; > end; > end; > drop i j l; > run; > > 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. > > Cherish > > > On Tue, Aug 25, 2009 at 8:59 PM, Abc Unha <abcunha@yahoo.com> 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 >> strings? >> > >


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