Date: Tue, 13 Oct 2009 06:59:33 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Determining if a character string includes a phrase
Content-Type: text/plain; charset=ISO-8859-1
It is "double NOT" used to normalize the position to a "boolean".
boolean = NOT NOT indexW(.....);
On 10/13/09, Jack Clark <firstname.lastname@example.org> wrote:
> Will you explain the double caret operator from your solution below? I
> see that it is returning a 1 or 0 instead of the position in the string
> normally returned by INDEXW, but I am not familiar with the operator.
> Thank you,
> Jack Clark
> Senior Research Analyst
> phone: 410-455-6256
> fax: 410-455-6850
> University of Maryland, Baltimore County
> Sondheim Hall, 3rd Floor
> 1000 Hilltop Circle
> Baltimore, MD 21250
> Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Paul Dorfman
> Sent: Tuesday, October 13, 2009 1:41 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Determining if a character string includes a phrase
> Frankly, I fail to see why it seems to be difficult. Both INDEXw and
> functions are suited for the task, e.g.:
> data _null_ ;
> input text $64. ;
> text = translate (text, " ", ".,") ;
> array pp $ 64 p1-p3 ("the train", "the station", "and i wasn't on
> it") ;
> array phrase  ;
> do over pp ;
> phrase[_i_] = ^^ indexw (upcase (text), upcase (strip (pp))) ;
> end ;
> put phrase[*] ;
> cards ;
> 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.
> run ;
> A much more interesting and involved question would be what is the most
> efficient way to confirm or reject the presence or the phrase
> "the Raven still sitting above my door, his eyes all dreaming"
> "And the Raven, never flitting, still is sitting, still is sitting on
> pallid bust of Pallas just above my chamber door, and his eyes have all
> seeming of the demon that is dreaming".
> Any takers?
> Kind regards
> Paul Dorfman
> Jax, FL