Calculate months between two dates in SAS (1 Viewer)

Ben_Entrew

Registered User.
Local time
Today, 05:21
Joined
Dec 3, 2013
Messages
177
Hi all,
somehow I can't calculate the months between 20211231 and 20230228.

Code:
%let End =   %sysfunc(intnx(month,%sysfunc(today()),-4,e),YYMMDDN8.);
%let Begin = %sysfunc(intnx(year, %sysfunc(date()), -2, e),YYMMDDN8.);
%put &Begin;
%put &End;

%let count_months =%sysfunc(intck(month,&Begin.,&End.));
%put &count_months;

I get the following log statement:
WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution.
The result of the operations have been set to a missing value.

Can someone help me with sythax?

Many thanks in advance.

Kind regards,
Ben
 

Isaac

Lifelong Learner
Local time
Today, 05:21
Joined
Mar 14, 2017
Messages
8,777
What happens if you put month in single quotes?
 

Isaac

Lifelong Learner
Local time
Today, 05:21
Joined
Mar 14, 2017
Messages
8,777
I would also recommend isolating the problem further which will make troubleshooting a lot easier.

Just use ONE of those statements in your code, and see which one errs, for sure
 

Users who are viewing this thread

Top Bottom