BookmarkSubscribeRSS Feed
dash
Obsidian | Level 7
Hi all,
How can I calculate the age of patients from the date of birth. Thanks in advance
10 REPLIES 10
darrylovia
Quartz | Level 8
a quick google search of calculate age in sas pointed to this


http://support.sas.com/kb/24/567.html
statsplank
Calcite | Level 5
Hello dash, darrylovia, and everyone,

The example at http://support.sas.com/kb/24/567.html (Sample 24567: Calculate a person's age) involves calculation of number of months in the interval between birthday and current date, and the number of years as #months/12 etc.

I used to calculate the age as age=int((current-bday)/365.25). Using the data from the example I got the exact same values for age:

data birth;
input name $ bday :mmddyy10. current :mmddyy10.;
datalines;
Miguel 12/31/1973 12/14/2004
Joe 02/28/1976 12/14/2004
Rutger 03/29/1976 12/14/2004
Broguen 03/01/1976 12/14/2004
Susan 12/12/1976 12/14/2004
Michael 02/14/1971 12/14/2004
LeCe 11/09/1967 12/14/2004
Hans 07/02/1955 12/14/2004
Lou 07/30/1960 12/14/2004
;

data age;
set birth;
if bday ne . and current ne .
then age=int((current-bday)/365.25);
else age=.;
run;

proc print;
format bday current worddate20.;
run;


I was wondering if the {#months/12} has any advantages over what seems to me much simpler {#days/365.25} method. Can anybody tell me what are the pitfalls with {#days/365.25}?
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello StatsPlank,

I made some testing and found that these formulas gave different ages on at least two following examples:

1. Current=10Mar2011 Bday=01Mar2010
age(based on #month)=1
age(based on #days) = 0

2. Current=10Mar2011 Bday=01Mar2009
age(based on #month)=1
age(based on #days) = 2

Sincerely,
SPR
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
There are well-documented SAS functions for calculating AGE within the SAS system, as well as dealing with DATE and DATETIME type SAS variables. Very specifically, refer to the INTCK function in the SAS Language DOC, also with the SAS support site and supplemental technical/conference reference material (using your favorite website and/or Internet SEARCH technique).

Scott Barry
SBBWorks, Inc.
Cynthia_sas
SAS Super FREQ
Hi:
This is the paper I send to students. The answer depends on what your goal is. As the author points out...if you want to know what age someone will be in a specific year, you might use a different calculation than if you want to know what exact age someone will be on a specific day.
http://www2.sas.com/proceedings/sugi30/060-30.pdf

cynthia
Doc_Duke
Rhodochrosite | Level 12
Deb's paper (that Cynthia@SAS references) is nice. However, credit must be given to Billy Kreuter who came up with that formula (G) back in the dark ages of SAS 5.

http://support.sas.com/kb/24/808.html

For history buffs, if you dig deep enough into the SAS-L archives, you can find the original discussion and derivation.

I prefer the (...)/365.25 for statistical modeling as it carries more information about the age. However for tabular reports, especially with large data sets, Billy's formula gets it right for all but leap-babies.

Doc Muhlbaier
Duke
Cynthia_sas
SAS Super FREQ
Wow, I knew that formula had been around, but didn't realize how long. Thanks, Doc for the history!

cynthia
statsplank
Calcite | Level 5
Thank you everyone for contributing to this thread!

~Olya
rvsidhu035
Quartz | Level 8
data age(keep=age);
t_day="xxxxxxxxx"d;
d_birth="xxxxxxx'd;
age=intck("year",d_birth,t_day);
run;
ex;
data age(keep=age);
t_day="27dec2017"d;
d_birth="07jun1989"d;
age=intck("year",d_birth,t_day);
run;
art297
Opal | Level 21

@rvsidhu035: The original post you responded to was from 2011. Since 9.3 I think the best way to calculate age is to use the yrdif function (see: http://www.sascommunity.org/wiki/Tips:Calculating_Exact_Age_with_the_YRDIF_Function )

 

Art, CEO, AnalystFinder.com

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 10 replies
  • 7543 views
  • 0 likes
  • 9 in conversation