```Date: Mon, 17 Jan 2011 19:08:54 -0500 Reply-To: bbser 2009 Sender: "SAS(r) Discussion" From: bbser 2009 Subject: Re: equal 5 or not, easier way? Comments: To: Tom Abernathy In-Reply-To: <201101172352.p0HBm164007366@waikiki.cc.uga.edu> Content-Type: text/plain; charset="us-ascii" Thanks a lot, Tom. I like it. For "boolean answer", I thought we could just do this below. I do not understand why you mention that expression. if whichn(...) then ... Max -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Abernathy Sent: January-17-11 6:52 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: [SAS-L] equal 5 or not, easier way? I think it would be easiest to use the WHICHN function. If you want to turn it into a boolean answer then do: found=0 ne whichn(5,of q1-q5); On Mon, 17 Jan 2011 18:39:13 -0500, bbser 2009 wrote: >Joe > > > >Just realized an alternative way doing this: > > > >if not mod(q1*q2*q3*q4*q5, 5) then .... > > > >There would be a problem when one of those q's is decimal number. > > > >Anyway, I am more interesting in knowing if there is an easier way to >express the product of q1-q5? > > > >Max > > > >From: Joe Matise [mailto:snoopy369@gmail.com] >Sent: January-17-11 6:27 PM >To: bbser 2009 >Cc: SAS-L@listserv.uga.edu >Subject: Re: equal 5 or not, easier way? > > > >Something like that would work. I would add a few things: > >if find(catx('|','0',of q1-q5,'0'),'|5|') ... > >That way you don't count 15 or 25 or whatnot. I use | not , so that it >works on all NLS (I think some systems use ',' as the decimal separator). > >-Joe > >On Mon, Jan 17, 2011 at 5:21 PM, bbser 2009 wrote: > >If I could use more functions, then I know how to do it: > > > >if find(catx(",", of q1-q5)) then ... > > > >Is this what you would like to suggest? Thanks. > > > >Max > > > >From: bbser 2009 [mailto:bbser2009@gmail.com] >Sent: January-17-11 6:02 PM >To: 'Joe Matise' >Cc: 'SAS-L@LISTSERV.UGA.EDU' >Subject: RE: equal 5 or not, easier way? > > > >Joe > > > >I tried something like this, but failed. > >if catx(" ", of q1-q5) contains "5" then ... > > > >it seems that contains/? can not be used with if-statement? > > > >Max > > > >From: Joe Matise [mailto:snoopy369@gmail.com] >Sent: January-17-11 5:38 PM >To: bbser 2009 >Cc: SAS-L@listserv.uga.edu >Subject: Re: equal 5 or not, easier way? > > > >Not sure what Cody is suggesting, but there's an easy way with CATX >function... can you see it? > >-Joe > >On Mon, Jan 17, 2011 at 4:16 PM, bbser 2009 wrote: > >q1-q5 are all numeric variables, >WITHOUT using array, >I would like to see if any of them equals 5. > >Cody's book says this can be easily done using OR or IN operators. >I do not see how this can be easily done except for the "non-easy" way like >this "if q1=5 or q2=5 or ..." > >I tried something like this: > >if (q1-q5) (or in) (5) then ... > >Which of course does not work, but hopefully this helps you understand what >I am looking for. >Please help. Thanks. > >Max ```

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