Return to   Main EpiData page   Example page
Extended explanation of command MOD:

In EpiData there are two operators that give results of divisions of integer numbers: DIV and MOD. DIV returns the integer division and MOD returns the remainder of the division:
  1. 15 DIV 10 is equal to 1, while 15 / 10 is equal to 1.5
  2. 20 DIV 7 is equal to 2
Sometimes you are interested in the remainder of the division only:
  1. 15 MOD 10 is equal to 5 (because 15 - (15 DIV 10) equals 5 -- the remainder of the division is 5)
  2. 20 MOD 7 = 6
  3. 21 MOD 7 = 0
EpiData is rather sensitive when it comes to datatypes.
The MOD operator can only be used with integer numbers as parameters:

20 MOD 7 is a legal expression, but
20.5 MOD 7is not legal and
20.0 MOD 7 is not legal
Please note that numeric fields with a with larger than 4 characters is treated as a floating point number (with zero decimals) in EpiData. Imagine a field named FIELD1 which is a numeric field with 5 characters (defined as #####). And imagine another field called FIELD2 which is also numeric.

LET FIELD2 = FIELD1 MOD 2          will not be accepted because FIELD1 is considered a floating point number.
LET FIELD2 = Integer(FIELD1) MOD 2          will be the way to do it.

This last expression will assign the value 0 or 1 the the field FIELD2 no matter what number is entered in FIELD1.
You should be aware of a new option added in EpiData 1.3: Under Options | Advanced you can choose to see errormessages generated during handling of calculations in checkfiles. This option can help you in figuring out why a certain calculation in your checkfile doesn't work.