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:   Tue, 13 Oct 2009 12:58:18 -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: Determining if a character string includes a phrase
Comments:   To: Jack Clark <jclark@HILLTOP.UMBC.EDU>

Jack,

I call it "Boolean normalizing operator" because it turns any true value (i.e. anything not zero and not missing) to 1 and any false value (i.e. anything zero or missing) to 0. As _Null_ pointer out, same as mnemonic NOT NOT. Hence the following, where X is a numeric expression,

bool = ^^ X ; bool = not not X ;

are fully equivalent to

if X = 0 or missing (X) then bool = 0 ; else bool = 1 ;

or

if X then bool = 1 ; else bool = 0 ;

Another clever trick from the same bag is

bool = X = -X ;

It comes with a slight marring side effect. I will leave it to SAS-L to ponder which condition it tests for and what the side effect is. When, a long time ago, I showed it to Bob Virgile (renowned for his deep appreciatiion of such SAS artifacts) he called it "cute".

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

On Tue, 13 Oct 2009 07:40:52 -0400, Jack Clark <jclark@HILLTOP.UMBC.EDU> wrote:

>Paul, > >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 > > > > >Jack Clark >Senior Research Analyst >phone: 410-455-6256 >fax: 410-455-6850 >jclark@hilltop.umbc.edu > >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 > >Kevin, > >Frankly, I fail to see why it seems to be difficult. Both INDEXw and >FINDx >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 [3] ; > 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" > >in > >"And the Raven, never flitting, still is sitting, still is sitting on >the >pallid bust of Pallas just above my chamber door, and his eyes have all >the >seeming of the demon that is dreaming". > >Any takers? > >Kind regards >------------ >Paul Dorfman >Jax, FL >------------


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