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 (October 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Oct 2009 10:05:23 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Determining if a character string includes a phrase
Comments: To: "Kevin F. Spratt" <Kevin.F.Spratt@dartmouth.edu>
In-Reply-To:  <7.0.1.0.2.20091008102735.041f31c0@Dartmouth.Edu>
Content-Type: text/plain; charset=ISO-8859-1

That might be simpler, or not simpler, but not more complex.

FIND, INDEX and INDEXW functions might be useful for you; they identify a string inside another string. If there are no rules beyond 'must contain', then any of those are pretty much good to go. Use UPCASE or whatever to eliminate case. I didn't suggest these simply because of your AA not AAA rule.

PRXMATCH will still match these fine, and whether or not you need any other special rule it will adapt fine. So:

prxmatch('/THE TRAIN/',upcase(varstr)) will return nonzero if THE TRAIN is in the string, zero if it isn't. If you need to eliminate duplicates or other things, you can use [^(phrase)] and/or \A & \Z similarly to how I did in my second post.

-Joe

On Thu, Oct 8, 2009 at 9:43 AM, Kevin F. Spratt < Kevin.F.Spratt@dartmouth.edu> wrote:

> Thanks Joe for the quick answer. > > Unfortunately, the answer to your fundamental question is No. > > I created a simple example but one that is not completely > generalizable to my problem > > A (hopefully) better example would be based on these three sentences: > > The train left the station, and I wasn't on it. > > I wasn't on it when the train left the station. > > The station was empty: the train had left without me. > > If the three phrases of interest are: (character case not important) > > "the train", "the station", and "and I wasn't on it" > > > For these three sentences, > > The first sentence has all three phases, the > second and third sentences do not have the third phrase. > > Phrase1 Phrase2 Phrase3 > 1 1 1 > 1 1 0 > 1 1 0 > > Sorry for the sloppy example. > > > > ______________________________________________________________________ > > Kevin F. Spratt, Ph.D. > Department of Orthopaedic Surgery > Dartmouth Medical School > One Medical Center Drive > DHMC > Lebanon, NH USA 03756 > (603) 653-6012 (voice) > (603) 653-6013 (fax) > Kevin.F.Spratt@Dartmouth.Edu (e-mail) > _______________________________________________________________________ > >


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