SAS DATE

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
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,204

Re: SAS DATE

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,204

Re: SAS DATE

data have;

date1='16MAR2011'd;                  

date2='10JAN1964'd;

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

run;

Super Contributor
Posts: 1,040

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,204

Re: SAS DATE

What is your date1?

Super Contributor
Posts: 1,040

Re: SAS DATE

date1=16MAR2011

date2=10JAN1964

Solution
‎10-09-2014 04:02 PM
Trusted Advisor
Posts: 1,204

Re: SAS DATE

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: 10,500

Re: SAS DATE

Your order is different the OP.

Super User
Posts: 10,500

Re: SAS DATE

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,040

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,363

Re: SAS DATE

Super User
Posts: 9,681

Re: SAS DATE

difference=yrdif (date2,date1);

☑ This topic is SOLVED.

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

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