# MOD macro

The `MOD` macro is available in Unica Campaign and Unica Interact.

## Syntax

`data MOD divisor data % divisor`

## Parameters

`data`

The integer values to compute the modulo of. This can be a constant value, a column, a cell range, or an expression evaluating to any of the above. For the format definition of `data`, see the "Macro Function Parameters" section in the chapter in this guide for your product.

`divisor`

The non-zero base integer to compute the modulo in respect to. This can be a constant value, a column, a cell range, or an expression evaluating to any of the above. The number of columns in `divisor` must equal the number of columns in `data`, unless `divisor` is a constant. For the format definition of `divisor` (same as `data`), see the "Macro Function Parameters" section in the chapter in this guide for your product.

## Description

`MOD` calculates the remainder of dividing the specified data range by a specified value. This is computed by dividing `divisor` into each value and returning the remainder. It returns one new column for each input column, each containing the numbers in `data` modulo `divisor`. The remainder will have the same sign (positive or negative) as `data`.

If `divisor` is a constant, each value in the specified column is calculated modulo that value. If `divisor` is a column, the calculations are performed on a row-by-row basis. The values in `data` are calculated modulo the first row value of `divisor`, the second row with the second row, and so on. This row-by-row calculation produces a result for each row up to the last value of the shortest column.

Note: If `divisor` is zero, a divide by zero error is returned.
Note: The `MOD` operator can be abbreviated with the percent sign ( `%`). For example, `TEMP` `=` `5 % 3` is equivalent to `TEMP` `=` ```5 MOD 3```.

## Examples

 `TEMP = 10 MOD 8` or `TEMP = 10 % 8`Creates a new column named `TEMP` containing the value `2`. `TEMP = -10 % 8`Creates a new column named `TEMP` containing the value `-2`. `TEMP = V1 % 8`Creates a new column named `TEMP`, where each value is the contents of column `V1`, modulo eight. `TEMP = V1:V3 % 2`Creates three new columns named `TEMP`, `VX`, and `VY`. The values in the `TEMP` column are the values modulo two of the contents of column `V1`, the values of the `VX` column are the values modulo two of the contents of column `V2`, and the values of the `VY` column are the values modulo two of the contents of column `V3`. `TEMP = V1 % V1`Creates a new column named `TEMP`, containing a zero for each entry in the column `V1`. This is because every number modulo itself is zero. `TEMP = V1 % V2`Creates a new column named `TEMP`, where each value is the row value of column `V1` modulo the corresponding row value of column `V2`. Note that if `V2=V1`, then all zeros are returned, as in the previous example. `TEMP = V1:V3 % V4:V6`Creates three new columns named `TEMP`, `VX`, and `VY`. The column `TEMP` contains the values in `V1` modulo the corresponding row values of column `V4`. The column `VX` contains the results of column `V2` modulo `V5`. The column `VY` contains the results of column `V3` modulo `V6`. `TEMP = V1[10:20] % V2` or ```TEMP = V1[10:20] % V2[1:11]```Creates a new column named `TEMP`, where the first 11 cells are the values of the values in rows 10-20 of column `V1` modulo the values in rows 1-11 of column `V2`. The other cells in `TEMP` are empty.

## Related functions

Function Description
`DIV` Divides one specified data range by another
`MOD` Computes the modulo of the contents of the specified data range