That's cool David -
Modz seems like a good way to get into trouble, you better understand
numeric representation pretty darn good.
If things get too large or small then they both return missing: "Both the
MOD and MODZ functions return a missing value if the remainder cannot be
computed to a precision of approximately three digits or more."
Thanks for the tip, I hadn't thought of using MOD on non-integers. Looks
like it's useful for all rationals.
regards
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of David
L. Cassell
Sent: Thursday, May 19, 2005 2:04 PM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: what is sas module operator?
Post by Jianping ZhuI need to find if a number is odd or ever, what is module operator in
sas
It's not the 'module' operator, it's the 'modulus' function,
from number theory. Try:
y = mod(x,2);
mod(x,2) will take a number X, and subtract multiples of two until the
result is between zero and two (not including two). If you start with
a whole number X, mod(x,2) will give you 1 when your number is odd and
0 when your number is even.
As of SAS 9, mod() has an extra feature, in that it does a certain
amount
of fuzzing too. This is quite handy when you're using mod() on really
large integers or numbers which are not integers. If you are running
SAS 9 and you want the non-fuzzing version, use the MODZ() function
instead.
HTH,
David
--
David Cassell, CSC
***@epa.gov
Senior computing specialist
mathematical statistician