Age
Note: Apparently, the build in datediff() function does not handle counting whole years. This results in wrongly counting age higher around the date of birth.
Age integer
Note: as opposed to the build in datediff() this handles counting years as integers very well. Calculate decimal years in statistical programming software. In R you can use with(ds, stRoke::age_calc(dob, inclusion)).

if([cpr]!="" and [inclusion]!="", datediff([dob], [inclusion], 'y'), "")
if([cpr]!="", left([inclusion], 4)-left([dob], 4) - if(mid([dob], 6, 2) < mid([inclusion], 6, 2) or (mid([dob], 6, 2) = mid([inclusion], 6, 2) and mid([dob], 9, 2) <= mid([inclusion], 9, 2)), 0, 1),"")
if([event_datetime]!="", left([event_datetime], 4)-left([inclusion_arm_1][dob], 4) - if(mid([inclusion_arm_1][dob], 6, 2) < mid([event_datetime], 6, 2) or (mid([inclusion_arm_1][dob], 6, 2) = mid([event_datetime], 6, 2) and mid([inclusion_arm_1][dob], 9, 2) <= mid([event_datetime], 9, 2)), 0, 1),"")
1, TIA | 2, AIS | 3, ICH | 4, SAH | 99, Unknown

@CALCTEXT(if([cpr]!="",if((right([cpr],1)=1 or right([cpr],1)=3 or right([cpr],1)=5 or right([cpr],1)=7 or right([cpr],1)=9),"male","female"),""))