Tag Archives: spss

Ceiling and Floor Computation in SPSS

Someone forgot to add CEILING and FLOOR functions to SPSS. Thankfully with a little logic and rounding, we can accomplish the same thing.

Antti Nevanlinna posted this solution on mathkb.com:

floor(x) = rnd(x) – 1*(rnd(x) > x)
ceil(x) = rnd(x) + 1*(rnd(x) < x)

The function rnd is a rounding function that does what you would expect: up for >= .50 and down for < .50.
The expression (rnd(x) < x) is a logical statement that will evaluate to 1 if true and 0 if false.

I am posting it here as a reminder for myself and as a service to anyone else looking to do the same thing.