Date: Fri, 18 Jan 2002 13:01:49 +0000
Reply-To: dkb@CIX.COMPULINK.CO.UK
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: dkb@CIX.COMPULINK.CO.UK
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
calculate
> the exact age using that old favourite macro
>
> %macro age(birth, refer);
> int((intck('month',&birth,&refer)-(day(&birth)>day(&refer)))/12);
> %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
birthday in
> the year corresponding to refer-date to refer-date itself.
David,
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.
Kind regards,
Dave
.
|