Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


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:

1 Calculating age in years

2 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!

3 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 JLS PXS MXS SXS SAS RES RAN ; run;

4 Sample code – 2 of x from VIEWTABLE of data: testing

5 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;

6 Printout of results: Age at run date ( )

7 Age on

8 Age on

9 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


Download ppt "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."

Similar presentations


Ads by Google