Posts

Showing posts with the label intck

How to calculate number of years and number of days between 2 dates;

How to calculate number of years and number of days between 2 dates; Exploring the yrdif and datdif functions in SAS as well as INTCK function: There are several ways to calculate the number of years between two dates and out of all the methods, YRDIF function results the most accurate value. Syntax: ageinyrs = YRDIF(birthdate, enddate, ' act/act '); ag_indays = DATDIF(birthdate, enddate, ' act/act '); “ act/act ” will gives us the actual interval between the two dates. The YRDIF function returns the calculated years between two SAS date values. The returned value will be a precise calculation, including multiple decimal places. Whereas with INTCK function will just give the rounded value like 10, 11 and not like 10.2 and 11.5. Syntax: Using YRDIF function: To know the interval between two dates in Years: data _null_; sdate=" 12mar1998 "d; edate=" 12jun2008 "d; years=yrdif(sdate,edate, 'act/act' ); put years ; run ; ...

Accurately Calculating Age with Only One Line of Code

direct link: This tip was written by William Kreuter , a senior computer specialist at the University of Washington in Seattle. He has used SAS software in public health research since 1981, and now specializes in manipulating large data sets for the School of Public Health and the School of Medicine. He can be reached at billyk@u.washington.edu. A frequent need of SAS software users is to determine a person's age, based on a given date and the person's birthday. Although no simple arithmetic expression can flawlessly return the age according to common usage, efficient code to do so can be written using SAS software's date functions. This article, by SAS software user William Kreuter, presents a one-line solution for this purpose. Put SAS Date Functions to Work for You Many kinds of work require the calculation of elapsed anniversaries. The most obvious application is finding a person's age on a given date. Others might include finding the number of years since any ...