Presentation on theme: "Calculating age in years. As usual more than one way Old school ageinyrs=int((date of interest- birth date)/365.25); works fine! Newer ageinyrs=intck(‘year’,birth."— Presentation transcript:
As usual more than one way Old school ageinyrs=int((date of interest- birth date)/365.25); works fine! Newer ageinyrs=intck(‘year’,birth date, date of interest); works, but be careful! Newer still ageinyrs=floor(yrdif(birth date, date of interest, `act/act´); works too!
Sample code – 1 of x *** create a test data set; data testing; informat name $3. bdate rundt future1 future2 yymmdd10.; format bdate rundt future1 future2 yymmddd10.; rundt=today(); future1='28Feb2024'd; future2='29Feb2024'd; input name bdate @@; datalines; MCB 1934-05-26 JLS 1932-12-15 PXS 1960-04-21 MXS 1962-06-06 SXS 1964-05-28 SAS 2001-10-21 RES 2005-02-01 RAN 1980-02-29 ; run;
Sample code – 2 of x from VIEWTABLE of data: testing
Sample code – 3 of x *** calculate the patient's age as of the date the program was run; data ages; set testing; *** on the run date of the program; age_m1=int((rundt-bdate)/365.25); age_m2=intck('year',bdate,rundt); age_m3=floor(yrdif(bdate,rundt,'act/act')); *** what about dates in the future?; age_m1_f1=int((future1-bdate)/365.25); age_m2_f1=intck('year',bdate,future1); age_m3_f1=floor(yrdif(bdate,future1,'act/act')); *** what about dates in the future leap years?; age_m1_f2=int((future2-bdate)/365.25); age_m2_f2=intck('year',bdate,future2); age_m3_f2=floor(yrdif(bdate,future2,'act/act')); run;
Printout of results: Age at run date (2013-10-17)
All methods work … but Careful of using the intck function when calculating age this function was developed to determine intervals for time series analysis and may round data in ways that aren’t intuitive for age calculations
Your consent to our cookies if you continue to use this website.