By on May 29, 2013 under SPSS Date and Time Variables.

Compute Age

Summary

In some cases, one would like to calculate respondents' age given their birthday. As long as birthday is an actual date variable, age is readily calculated by using the DATEDIFF function.

Copy-paste-run the syntax below for a demonstration of DATEDIFF.

SPSS Datediff Syntax Example

*1. Create test data.

data list free/bday(a10).
begin data
15-09-1978
15-11-1990
11-10-1976
end data.

*2. Convert birthday into date variable.

alter type bday(edate10).

*3. Compute current age.

compute age_years=datediff($time,bday,"years").
compute age_months=mod(datediff($time,bday,"months"),12).
exe.

Explanation

Comment on this Tutorial

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

Current ye@r *