The following are examples of how age can be calculated in MCHP data A. AGE AS OF SOME CONSTANT DATE This means picking a specific constant date, e.g. 92/12/31, and subtracting the birth year from this value: SAS CODE: || bthyr = input(substr(birth date,1,4),4.) || age4 = year - bthyr ; /* year is study dependent, CCYY */ NOTE: BIRTH DATE must be at least $CHAR4 (ccyy), and year (study dependent) must be $CHAR4 (ccyy). CAUTION: The choice of year (the common year at which age is to be calculated) is critical. The common year should be a year that will include all claimants in year of question. MCHP's data is organized by fiscal year (e.g. April 1, 1990 to March 31, 1991). A problem that is possible using the MCHP's database is that end of fiscal year may make individuals 1 year older than expected. But if year is prior to any possible claims, the age may be negative. B. AGE AT MONTH END OF THE CLAIM MONTH Hospitals and physicians submit claims to Manitoba Health for services provided in order to be reimbursed (for more information read the file MCHP Database). To calculate the age at the month end of the claim month, the date admitted to the hospital for services is often used. However, the date that is chosen to be used is study dependent. The admit date is often used because a claim for that service will likely be submitted within the month of service. SAS CODE: || xdate=190000+input(substr(admitdate,1,4),4.) ; /* becomes "ccyymm" */ || age6 = floor(.01 * (xdate - input(birth date,6.))); NOTE: BIRTH DATE must be at least $CHAR6 (ccyymm), and ADMIT DATE must be at least $CHAR4 (yymm). C. EXACT AGE FOR A PARTICULAR DATE If a particular date is preferred, for example, age at date of discharge, then birth date is subtracted from the chosen date. In this example the date of admission is used. SAS CODE: || xdate = 19000000 + input(admit date,6.); /* admit date becomes "ccyymmdd" */ || age8 = floor(0.0001 * (xdate-input(birth date,8.))) ; NOTE: BIRTH DATE must be $CHAR8 (ccyymmdd), and ADMIT DATE (or DISCHARGE DATE or SURGERY DATE) must be $CHAR6 (yymmdd). CAUTION: Physician claims data do not generally contain day of birth in birth date, therefore the birth day must come from an external source. [E.g. linkage with data from Vital Statistics]. D. CENTURY ADJUSTMENT (developed by Pat Nicol) Some of the birth dates in the data contain badly coded century values. An estimate of the year must be made. The following provides a stable estimate of the century. For this example the claim year is found from admit date: SAS CODE: || xbcym = birth date; /* ccyy or ccyymm or ccyymmdd */ || if not('18' <= substr(xbcym,1,2) <= '20') /* if century not between 18 and 20, then */ || then substr(xbcym,1,2) = put ((19 - (substr(xbcym,3,2) > substr(admit date,1,2))),z2.); || /* change century to 19 if the claim year is greater than the birth year, || or to 18 if the claim year is less than the birth year. */ NOTE: BIRTH DATE must be at least $CHAR4 (ccyy) claim year must beat least $CHAR2 (yy). CAUTION: There is a problem with this fix since individuals who are 100+ will be assigned an age of 0+. If possible, Charles Burchill suggests going to the research registry to find the birth date. E. CALCULATING AGE IN YEARS AND DAYS (from SAS.com) 1. Version 8 base SAS software includes a new function called YRDIF. Here's an example: To find the number of years between two dates: YRDIF('01OCT1982'd,'01JAN2000'd,'ACT/ACT')= 17.252 This also provides a simple, accurate calculation of age: age = INT(YRDIF('01OCT1982'd,'01JAN2000'd,'ACT/ACT')); 2. Another function available in version 8 and later, DATDIF is very useful for calculating the number of years and days between any two dates. data dates ; retain birth "02jan2001"d ; do refer = "31dec2001"d, "01jan2002"d, "02jan2002"d, "03jan2002"d ; output ; end ; run ; data _null_ ; set dates ; age = int(yrdif(birth,refer,'actual')) ; days = datdif(mdy(month(birth),day(birth),year(refer)),refer,'actual') ; if days < 0 then days = datdif(mdy(month(birth),day(birth),year(refer)-1),refer,'actual'); put age = "Years and " days "days" ; run ;