To find the amount of time that has passed between any two dates you subtract them, but the years have to be converted to months by multiplying by twelve:
gen ageInMonths=(interviewYear-birthYear)*12 + (interviewMonth-birthMonth)
To find age in whole years you need to divide by 12 and drop the fractional part. Stata will drop the fractional part automatically if you declare your new variable to be an int:
gen int age=ageInMonths/12
Complete do file:
clear all
set more off
capture log close
log using data_ex2.log, replace
use interviews
gen ageInMonths=(interviewYear-birthYear)*12 + (interviewMonth-birthMonth)
gen int age=ageInMonths/12
list
log close
Last Revised: 12/17/2015