Functions and CALL Routines |
Category: | Mathematical |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
See Also |
Syntax |
MOD (argument-1, argument-2) |
is a numeric constant, variable, or expression that specifies the dividend.
is a numeric constant, variable, or expression that specifies the divisor.
Restriction: | cannot be 0 |
Details |
The MOD function returns the remainder from the division of argument-1 by argument-2. When the result is non-zero, the result has the same sign as the first argument. The sign of the second argument is ignored.
The computation that is performed by the MOD function is exact if both of the following conditions are true:
All integers that are less than either argument have exact 8-byte floating-point representations.
To determine the largest integer for which the computation is exact, execute the following DATA step:
data _null_; exactint = constant('exactint'); put exactint=; run;
Operating Environment Information: You can also refer to the SAS documentation for your operating environment for information about the largest integer.
If either of the above conditions is not true, a small amount of numerical error can occur in the floating-point computation. In this case
MOD returns zero if the remainder is very close to zero or very close to the value of the second argument.
MOD returns a missing value if the remainder cannot be computed to a precision of approximately three digits or more. In this case, SAS also writes an error message to the log.
Note: Before SAS 9, the MOD function did not perform the adjustments to the remainder that were described in the previous paragraph. For this reason, the results of the MOD function in SAS 9 might differ from previous versions.
Comparisons |
Here are some comparisons between the MOD and MODZ functions:
The MOD function performs extra computations, called fuzzing, to return an exact zero when the result would otherwise differ from zero because of numerical error.
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.
Examples |
The following SAS statements produce results for MOD and MODZ.
See Also |
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.