SAS DATE

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

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
Trusted Advisor
Posts: 1,228

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;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,228

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

Trusted Advisor
Posts: 1,228

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
Trusted Advisor
Posts: 1,228

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: 11,343

Re: SAS DATE

Your order is different the OP.

Super User
Posts: 11,343

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: 7,474

Re: SAS DATE

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

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
  • 347 views
  • 6 likes
  • 5 in conversation