LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 21 Jul 2011 08:10:43 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Figuring out Age in Years, Months and Days
Comments: To: John.V.Parker@kp.org
In-Reply-To:  <CAEZCysubTwxBgWhhOtiFL+BsaYm_hOWWSPGxm+rmOhy7YSJG8g@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

You will need to drop WEEKS it is not part of ISO8601 standard. But I suppose if you insist it can be easily derived from nD, with nD reduced accordingly.

This example converts S(seconds) a DUration to I(SO8601) DUration. Notice I also converted the start and end dates to SAS datetime.

I borrowed Mark Miller's data.

data test; input (BD DD)(:yymmdd.); BD = dhms(bd,0,0,0); DD = dhms(dd,0,0,0); S = dd-bd; length i $16 dur $64; call IS8601_CONVERT('DU','DU',s,i); dur = put(i,$n8601e.); substr(dur,index(dur,'T')) = ' '; format BD DD dtdate. i $n8601e.; DATALINES4; 19131230 19131230 19131230 19131231 19131231 20110601 19140101 20110602 19140201 19140202 19140201 19140206 19140201 19140207 19140201 19140208 19140201 19140228 19440111 20100103 19450627 20110627 19451012 20110512 19451012 20110511 19451012 20110513 19990227 20000228 19990227 20000229 20000201 20000229 20000201 20000301 20000228 20010227 20000229 20010301 20071012 20100421 20071012 20081011 20071012 20081012 20071012 20081013 20071012 20081014 20071012 20071021 20071012 20071029 20011221 20020102 ;;;; run; proc print; run;

On Wed, Jul 20, 2011 at 4:39 PM, Data _null_; <iebupdte@gmail.com> wrote: > I haven't used this and don't know much about the subject but it may > be of some use. Place to start anyway. > > CALL IS8601_CONVERT Routine > > -------------------------------------------------------------------------------- > > Converts an ISO 8601 interval to datetime and duration values, or > converts datetime and duration values to an ISO 8601 interval. > > On Wed, Jul 20, 2011 at 4:30 PM, John Parker <John.V.Parker@kp.org> wrote: >> Hi All, >> >> I have a requirement to figure out Age at Death and it has to be expressed >> in Years, Months, Weeks and Days. >> >> This is to accommodate individuals who may have died a short period after >> childbirth, etc. >> >> In the past I have used code like this: >> >> Age_at_death=%calcage(birth_date, death_date); >> >> %macro CalcAge(BDtVar, RefDate) ; >> >> floor ((intck('month',&BDTVar,&RefDate) - (day(&RefDate) < day(&BDTVar))) >> / 12) >> >> %mend CalcAge ; >> >> The DOB and DOD variables are formatted as MMDDYY10. >> >> Has anyone done this type of calculation to this degree? >> >> Many Thanks! >> >> John >> >


Back to: Top of message | Previous page | Main SAS-L page