Age Is Just a Number: Accurately Calculating Integer and ...
Age Is Just a Number: Accurately Calculating Integer and Continuous Age
Sara Adams and Chris Colby, ICON Clinical Research, San Francisco, CA
ABSTRACT Are you still dividing by 365.25 to calculate age? Computing integer age and continuous age are common programming tasks? yet they are often done imprecisely. By utilizing the SAS date function INTCK, it is possible to calculate integer age in one line of code so that age increments exactly on a person's birthday. Continuous age on an event date is calculated as the integer age plus the proportion of the year that has elapsed since the prior birthday. This paper will present code that precisely calculates both integer and continuous age.
INTRODUCTION "Age is just a number" (Lexi Starling), so it might as well be an accurate one. In common usage, age is an integer that increments exactly on a person's birthday. In statistical analysis, age is sometimes defined as an integer (e.g. 5 years) and sometimes as a continuous variable (e.g. 5.89 years). Given a person's date of birth and a subsequent event date in SAS, it is straightforward to calculate how many days the person has been alive (i.e. subtract the date of birth from the event date), but it is more challenging to determine exactly the person's age on the event date. In this paper, we will present a method of calculating integer age so that age increments exactly on a person's birthday. We will also introduce an accurate method for calculating continuous age defined as the integer age plus the fraction of the year that has elapsed since the prior birthday.
INTEGER AGE ? IMPRECISE METHODS
First, we review several imprecise methods for calculating integer age. The example
code in the table assumes SAS date variables are provided for date of birth (DOB) and
for a subsequent event date.
Integer Age Methods*
50th Birthday for DOB = 17JUN2000
floor((eventdate-dob)/365.25)
18JUN2050
floor((eventdate-dob)/365)
05JUN2050
year(eventdate)-year(dob)
01JAN2050
floor(yrdif(dob,eventdate,'act/act'))
18JUN2050
floor(intck(`month',dob,eventdate)/12)
01JUN2050
* Other methods use the INT function instead of the FLOOR function. The INT function returns the integer portion of the argument, while the FLOOR function returns the largest integer that is less than or equal to the argument. When the evaluated argument is positive, the INT and FLOOR functions return the same value.
As this table shows, results deviate from the correct 50th birthday (June 17, 2050) depending on the method chosen. In an extreme case, the birthday is off by over five months. The floor((eventdate-dob)/365) method is off by 12 days because it does not account for the leap days that occurred between 2000 and 2050.
- 1 -
Why accept any amount of imprecision? There are situations when a few days matter. For example, certain benefits are activated on a person's birthday, such as Social Security on an individual's 65th birthday or health insurance coverage for a mammogram on a woman's 40th birthday. On a practical level, if each programmer uses a different method for calculating age, then the analysis results may differ. Using an accurate method for calculating age ensures that your results are reproducible.
INTEGER AGE ? ACCURATE AGE CALCULATION WITH INTCK The following code calculates integer age so that it always increments age exactly on a person's birthday:
FLOOR((INTCK('month',dob,eventdate)-(day(eventdate) ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- destring — convert string variables to numeric
- unsigned and signed integers
- cs429 computer organization and architecture integers
- bits bytes and integers
- age is just a number accurately calculating integer and
- secure coding in c integers
- integer security northern kentucky university
- c programming examples princeton university
- 11 formulating and solving integer programs
Related searches
- the sum of a number times 2 and 22 is as most as 21
- twice the difference of a number and 4 is at least 16
- the sim of a number times 2 and 21 is at least 23
- five subtracted from the product of 7 and a number is at least 16
- eight times the sum of a number and 22 is at least 29
- seven increased by the product of a number and 5 is greater than 20
- half the product of five and a number is more than two
- the difference between a number and twice another number is at most 8
- fourth subtracted from the product of 10 and a number is at least 29
- the difference of twice a number and 4 is greater than 30
- the sum of a number times 3 and 17 is greater than 28
- a number p is fewer than 15 and at least 1