turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Health Care and Pharma
- /
- SAS in Health Care Related Fields
- /
- Calculate age

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 02:04 AM

Hi all,

How can I calculate the age of patients from the date of birth. Thanks in advance

How can I calculate the age of patients from the date of birth. Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 08:57 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 10:18 AM

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}?

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}?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 11:18 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 11:43 AM

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.

Scott Barry

SBBWorks, Inc.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 02:20 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 04:38 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2011 10:17 PM

Wow, I knew that formula had been around, but didn't realize how long. Thanks, Doc for the history!

cynthia

cynthia

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-11-2011 09:58 AM

Thank you everyone for contributing to this thread!

~Olya

~Olya