By on May 29, 2013 under 7.1. SPSS Popular FAQ.

7.1.2. Compute Age

Summary

In some cases, one would like to COMPUTE 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

Comments for this Tutorial have been Closed

This Tutorial has One Comment: