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 (May 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 24 May 2005 10:37:28 -0400
Reply-To:   "Sridhar, Kumar" <nsridhar@MEDAREX.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Sridhar, Kumar" <nsridhar@MEDAREX.COM>
Subject:   Re: Question on Proc SQL
Comments:   To: Kevin Roland Viel <kviel@EMORY.EDU>
Content-Type:   text/plain; charset="iso-8859-1"

Kevin:

Thanks for your suggestion. I did use floor() function after getting your email and you're right, there is a difference in the age.

Thanks for the suggestion. But I have a question in regards to the difference (and it maybe a naïve question) but would you know why the difference occurs?

Thanks

Kumar

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kevin Roland Viel Sent: Tuesday, May 24, 2005 10:32 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Question on Proc SQL

> int((consdtn-birthdtn)/365.25) as age

Kumar,

This does not always return the age you might expect. I suggest the YRDIF() function, for instance. Also, why not just use the FLOOR() function, since you expect age to be positive anyway?

Consider:

993 data _null_ ; 994 995 /* AGE = 1 , born in non-leap year */ 996 birthdtn = mdy( 01 , 01 , 2003 ) ; 997 consdtn = mdy( 01 , 01 , 2004 ) ; 998 999 diff = intck( "DAYS" , birthdtn , consdtn ) ; 1000 1001 d1 = int((consdtn-birthdtn)/365.25) ; 1002 d2 = floor( yrdif( birthdtn , consdtn , "actual" )) ; 1003 1004 put birthdtn= mmddyy10. consdtn= mmddyy10. ; 1005 put diff= d1= d2= / ; 1006 1007 /* Year - 1981 = 5 , 10 , 15 , 20 (why 20?),... */ 1008 birthdtn = mdy( 01 , 01 , 1981 ) ; 1009 consdtn = mdy( 01 , 01 , 1986 ) ; 1010 1011 diff = intck( "DAYS" , birthdtn , consdtn ) ; 1012 1013 d1 = int((consdtn-birthdtn)/365.25) ; 1014 d2 = floor( yrdif( birthdtn , consdtn , "actual" )) ; 1015 1016 put birthdtn= mmddyy10. consdtn= mmddyy10. ; 1017 put diff= d1= d2= / ; 1018 1019 run ;

birthdtn=01/01/2003 consdtn=01/01/2004 diff=365 d1=0 d2=1

birthdtn=01/01/1981 consdtn=01/01/1986 diff=1826 d1=4 d2=5 NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

Regards,

Kevin

Kevin Viel Department of Epidemiology Rollins School of Public Health Emory University Atlanta, GA 30322


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