07-16-2015 04:06 PM
I'm not sure exactly what you're asking for, are you looking to create a variable with today's date in the format ddmmyyyy? Or what specifically are you wanting the output or variable to look like and in what format? You could create a macro variable and call it, or you could create a field in a data set equal to the same value....
format today ddmmyyn8.;
A little more information of what you're looking to do with it, or what expected output you want would help.
07-16-2015 04:58 PM
This is what I have right now -
format today DATETIME22.3;
today = today();
year = year(today());
age = year - year(datepart(birth_date));
if birth_date > today then age=age-1;
But if someone has NOT had a birthday this year, then it is automatically assuming they have, and adding a year when it should not. I just want to see the age in whole numbers, with no decimals.
07-17-2015 08:47 AM
As morgalr previously showed, I would look into the INTCK() or INTNX() function. You can specify what you what you want to subtract from two separate dates, in this case years from today's date and the date of birth_date. I would recommend going and researching that route as that is the best and most accurate way to subtract two dates.
Hope that helps!
07-16-2015 05:25 PM
I think this will give you the results you desire in myYears, myMonths, myDays:
myBirthday = '05-AUG-1974'd;
myDate = today();
myYears = intck('YEAR', myBirthday, myDate, 'C');
myBirthday = intnx('YEAR', myBirthday, myYears, 'SAME');
myMonths = intck('MONTH', myBirthday, myDate, 'C');
myBirthday = intnx('MONTH', myBirthday, myMonths, 'SAME');
myDays = intck('DAY', myBirthday, myDate, 'C');
keep myYears myMonths myDays;
07-16-2015 05:34 PM
It really helps if you provide some example start data, in this case probably a couple of Birthdates and the date you want the value(s) calculated. Then for the same data show the desired results.
The answer to the question is yes. The details of how depend on the actual desired result.
07-17-2015 09:20 AM
To do that I use to call the rolland macro AGEDEC
It have even a parameter to decide where a subject born in 29FEB must be birthdate only on 29FEB or in 1MAR.
07-17-2015 11:28 AM
This worked. I needed to round using floor. I was having people show up as 65, even if they are actually 64 and haven't had their birthday yet this year.
age = floor((today()-birth_dateall)/365);