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
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
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.
On Thu, Oct 8, 2009 at 9:43 AM, Kevin F. Spratt <
> 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
> Lebanon, NH USA 03756
> (603) 653-6012 (voice)
> (603) 653-6013 (fax)
> Kevin.F.Spratt@Dartmouth.Edu (e-mail)