SAS DATE

Solved
Super Contributor
Posts: 1,041

SAS DATE

Hi I am trying to find the years between the two dates.

date1                    date2

16MAR2011     10JAN1964

difference=date1-date2

this gives me in seconds....

How can I get years??????

Thanks

Accepted Solutions
Solution
‎10-09-2014 04:02 PM
Posts: 1,270

Re: SAS DATE

Posted in reply to robertrao

Not sure, I am using the same and getting 47.

data have;

date1='16MAR2011'd;

date2='10JAN1964'd;

difference=intck('year',date2,date1);

run;

All Replies
Posts: 1,270

Re: SAS DATE

Posted in reply to robertrao

data have;

date1='16MAR2011'd;

date2='10JAN1964'd;

difference=intck('year',date2,date1);

run;

Super Contributor
Posts: 1,041

Re: SAS DATE

difference=intck('year',date2,date1);

I tried the above and it gives me negative age in years

Do I need to do:

difference=intck('year',date1,date2);

Thanks

Posts: 1,270

Re: SAS DATE

Posted in reply to robertrao

What is your date1?

Super Contributor
Posts: 1,041

Re: SAS DATE

date1=16MAR2011

date2=10JAN1964

Solution
‎10-09-2014 04:02 PM
Posts: 1,270

Re: SAS DATE

Posted in reply to robertrao

Not sure, I am using the same and getting 47.

data have;

date1='16MAR2011'd;

date2='10JAN1964'd;

difference=intck('year',date2,date1);

run;

Super User
Posts: 13,563

Re: SAS DATE

Your order is different the OP.

Super User
Posts: 13,563

Re: SAS DATE

Posted in reply to robertrao

If that gives seconds you have DATETIME value, it should be Days if the values are actual SAS dates.

Do you need years as in and date in 2011 and any date in 1964 = 47 or do you need to calculate as if a calendar age?

Super Contributor
Posts: 1,041

Re: SAS DATE

Hi Ballard,

I have SAS dates and not datetimes. sorry for the confusion.

I think if we can get to the 47 that should be fine

also please let me know how to do the calendar age ....good to know

Thanks

PROC Star
Posts: 8,164

Re: SAS DATE

Posted in reply to robertrao
Super User
Posts: 10,784

Re: SAS DATE

Posted in reply to robertrao

difference=yrdif (date2,date1);

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 10 replies
• 381 views
• 6 likes
• 5 in conversation