DATA Step, Macro, Functions and more

I need to create exact one year from today

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

I need to create exact one year from today

Hi Team,

 

I want to create an year value and it should be exact one year from today irrespective of leap year or what ever I have tried the below code

 

test=intnx('month',today(),-12,'B');

 

But it was not giving exact exact one year difference it was giving 01-May-2015 but i need 12-May-2015 ie if the job is running today it should calculate exact one year difference.

 

Thanks

 

Manesh


Accepted Solutions
Solution
‎05-12-2016 10:40 AM
Super User
Posts: 19,877

Re: I need to create exact one year from today

Posted in reply to ambadi007

The last parameter for your intnx should be same. 

You also should use year and -1 interval. 

 

Intns('yeat', today(), -1, 's')

View solution in original post


All Replies
Super User
Posts: 7,866

Re: I need to create exact one year from today

Posted in reply to ambadi007

Have you tried

test = intnx('year',today(),-1);

?

If yes, and it did not give you your wanted result, what was the difference?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎05-12-2016 10:40 AM
Super User
Posts: 19,877

Re: I need to create exact one year from today

Posted in reply to ambadi007

The last parameter for your intnx should be same. 

You also should use year and -1 interval. 

 

Intns('yeat', today(), -1, 's')

Super User
Posts: 5,518

Re: I need to create exact one year from today

[ Edited ]

Also, you may want to compare these two to see if they give you the same results for leap years:

 

intnx('year', today(), -1, 'S')

 

intnx('month', today(), -12, 'S')

 

it's possible they are equivalent, but check for a Feb 28, Feb29, and March 1 date to see what you get.

 

 

***

 

I found time to test them ... they generate the same result.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 243 views
  • 1 like
  • 4 in conversation