| 1 | DATA test; |
| 2 | INPUT birthday date2; |
| 3 | informat birthday date2 date9.; |
| 4 | FORMAT birthday date2 date9.; |
| 5 | DATALINES; |
| 6 | 16APR1986 16APR2017 |
| 7 | 15APR1986 16APR2017 |
| 8 | 17APR1986 16APR2017 |
| 9 | 29FEB2016 28FEB2017 |
| 10 | 29FEB2016 27FEB2017 |
| 11 | 29FEB2016 01MAR2017 |
| 12 | ; |
| 13 | RUN; |
| 1 | PROC FCMP outlib=work.cat_function.test ; |
| 2 | function AgeToday(DateDay); |
| 3 | to = TODAY(); |
| 4 | bd = DateDay; |
| 5 | age = int((intck('month',bd,to)-(day(bd)>day(to)))/12); |
| 6 | return(age); |
| 7 | endsub; |
| 8 | RUN; |
| 1 | PROC FCMP outlib=work.cat_function.test ; |
| 2 | function AgeDate(Birthdate,Date); |
| 3 | to = Date; |
| 4 | bd = Birthdate; |
| 5 | age = int((intck('month',bd,to)-(day(bd)>day(to)))/12); |
| 6 | return(age); |
| 7 | endsub; |
| 8 | RUN; |
| 1 | options cmplib=work.cat_function; |
| 1 | DATA test; |
| 2 | SET test; |
| 3 | AgeT = AgeToday(birthday); |
| 4 | AgeD = AgeDate(birthday,date2); |
| 5 | RUN; |