library('data.table')
icdSample1 = merge(icdSample, demoSample[, .(person_id, dob)], by = 'person_id')
icdSample1[, occurrence_age := as.numeric((entry_date - dob)/365.25)]
icdSample1[, `:=`(entry_date = NULL, dob = NULL)]
dxStatus = getDxStatus(demoSample, icdSample1)
Run the code above in your browser using DataLab