SPSS Tutorials

BASICS REGRESSION T-TEST CHI-SQUARE TEST ANOVA

Modulus (General Concept)

Definition

The modulus is what's left of a given number after subtracting another given number from it as many times as possible.

1. SPSS Modulus Syntax Example

*1. Create Test Data.

data list free/number.
begin data
1
12
123
1234
12345
end data.

*2. Extract Last Two Digits.

compute last_two_digits=mod(number,100).
exe.

2. Python Modulus Example

*Inspect whether numbers from random sample are odd or even.

begin program.
import random
mySample = random.sample(range(10),5)
for i in mySample:
    if i % 2 == 0:
        print str(i) + " is an even number"
    else:
        print str(i) + " is an odd number"
end program.

Previous tutorial: Module (Python Concept)

Next tutorial: Path (General Concept)

Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

This tutorial has 1 comment!