Date: Fri, 18 Jan 2002 13:01:49 +0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Organization: Nextra UK
Subject: Re: age calculations etc
David Yeats asks:
> I have been puzzling over the following...
> Given the birth-date and another reference date refer-date I can
> the exact age using that old favourite macro
> %macro age(birth, refer);
> %mend age;
> where &birth and &refer are the two dates. Now what I need having
> calculated the age is exactly how many days are there from the
> the year corresponding to refer-date to refer-date itself.
You could do something like this:
referday = mdy(month(&birth),day(&birth),year(&refer));
numdays = referday - &refer;
This will a give negative result if the reference date is after the
birthday, positive if it's before. You may want to swap the terms round
in order to change the sign.