PROBLEM: EXPLANATION: SOLUTION:

ID               DOB              VISIT     DOBNEW   VISITNEW     AGE

 1  09MAY51:00:00:00   03JUN00:00:00:00   05/09/51   06/03/00  49.0705
 2  29FEB76:00:00:00   12APR01:00:00:00   02/29/76   04/12/01  25.1170
 3  31OCT38:00:00:00   30SEP01:00:00:00   10/31/38   09/30/01  62.9158
 4  12AUG25:00:00:00   28JAN00:00:00:00   08/12/25   01/28/00  74.4613
 5  01JAN64:00:00:00   24DEC01:00:00:00   01/01/64   12/24/01  37.9795

Another solution is to calculate the AGE variable from the original DOB and VISIT variables (in DATETIME format), and divide by the number of seconds in a year, which is

Here's the example, and the output:


data agecalc1; set accdata;
  format dob visit datetime18.
  age = (visit - dob) / 31557600;
proc print;
run;

ID                   DOB                 VISIT      AGE

 1      09MAY51:00:00:00      03JUN00:00:00:00    49.0705
 2      29FEB76:00:00:00      12APR01:00:00:00    25.1170
 3      31OCT38:00:00:00      30SEP01:00:00:00    62.9158
 4      12AUG25:00:00:00      28JAN00:00:00:00    74.4613
 5      01JAN64:00:00:00      24DEC01:00:00:00    37.9795