1 / 9

Tips and Tricks

Tips and Tricks. 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 date, date of interest); works, but be careful! Newer still

tillie
Télécharger la présentation

Tips and Tricks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tips and Tricks 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. bdaterundt future1 future2 yymmdd10.; format bdaterundt 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

More Related