 Functions and CALL Routines

# MODZ Function

Returns the remainder from the division of the first argument by the second argument, using zero fuzzing.
 Category: Mathematical

## Syntax

 MODZ (argument-1, argument-2)

### Arguments

argument-1

is a numeric constant, variable, or expression that specifies the dividend.

argument-2

is a non-zero numeric constant, variable, or expression that specifies the divisor.

The MODZ 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 MODZ function is exact if both of the following conditions are true:

• Both arguments are exact integers.

• All integers that are less than either argument have exact 8-byte floating-point representation.

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. For example, when you use exact arithmetic and the result is zero, MODZ might return a very small positive value or a value slightly less than the second argument.

Here are some comparisons between the MODZ and MOD functions:

• The MODZ function performs no fuzzing.

• 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 MODZ and MOD functions return a missing value if the remainder cannot be computed to a precision of approximately three digits or more.

The following SAS statements produce results for MOD and MODZ.

SAS Statements Results
```x1=mod(10,3);
put x1 9.4;```
`1.0000`
```xa=modz(10,3);
put xa 9.4;```
`1.0000`
```x2=mod(.3,-.1);
put x2 9.4;```
`0.0000`
```xb=modz(.3,-.1);
put xb 9.4;```
`0.1000`
```x3=mod(1.7,.1);
put x3 9.4;```
`0.0000`
```xc=modz(1.7,.1);
put xc 9.4;```
`0.0000`
```x4=mod(.9,.3);
put x4 24.20;```
`0.00000000000000000000`
```xd=modz(.9,.3);
put xd 24.20;```
`0.00000000000000005551`

 Functions: Previous Page | Next Page | Top of Page