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 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
Comments: To: Abc Unha <abcunha@YAHOO.COM>


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.) ; cards ; 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 ; run ;

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))) ; end ; run ;

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.

Kind regards ------------ Paul Dorfman Jax, FL ------------

On Tue, 25 Aug 2009 11:29:19 -0400, 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