DATA Step, Macro, Functions and more

DATE Calculation

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

DATE Calculation

Good Afternoon Guys,

 

Looking for some syntax help if you can Smiley Happy

 

I need to create an effective date which is always to be Dec 31st of the following year


Example


If my Creation Date is 8/18/2017 my effective date would be DEC 31 2018

 

If my Creation Date is 12/31/2017 my effective date woul dbe DEC 31 2018

 

Ect.

Appreciate any assistance


Accepted Solutions
Solution
‎08-17-2017 02:49 PM
PROC Star
Posts: 1,333

Re: DATE Calculation

Posted in reply to Bellefeuille

The INTNX function is incredible. I suggest you read up about it.

 

data have;
	format CreationDate EffectiveDate date.;
	CreationDate = '1jan2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
	CreationDate = '18aug2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
	CreationDate = '31dec2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
run;

 

 

 

 

Tom

View solution in original post


All Replies
Solution
‎08-17-2017 02:49 PM
PROC Star
Posts: 1,333

Re: DATE Calculation

Posted in reply to Bellefeuille

The INTNX function is incredible. I suggest you read up about it.

 

data have;
	format CreationDate EffectiveDate date.;
	CreationDate = '1jan2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
	CreationDate = '18aug2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
	CreationDate = '31dec2017'd;
	EffectiveDate = intnx('year', CreationDate, 1, 'end');
	output;
run;

 

 

 

 

Tom

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 118 views
  • 2 likes
  • 2 in conversation