Download presentation

Presentation is loading. Please wait.

Published byNya Daring Modified over 2 years ago

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

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 (2013-10-17)

7
Age on 2024-02-28

8
Age on 2024-02-29

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

Similar presentations

OK

Use the SET statement to: –create an exact copy of a SAS dataset –modify an existing SAS dataset by creating new variables, subsetting (using a subsetting.

Use the SET statement to: –create an exact copy of a SAS dataset –modify an existing SAS dataset by creating new variables, subsetting (using a subsetting.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google