I am trying to go through the loop from the start date and end date as follow:
Error:
Required operator not found in expression: YEAR(INTNX('MONTH', MDY(2,1,2020), 3, 'SAME'))*100+MONTH(INTNX('MONTH', MDY(2,1,2020), 3, 'SAME'))
Code:
%LET ENDING_YEAR = 2021;
%LET ENDING_MONTH = 3;
%LET STARTING_YEAR = 2020;
%LET STARTING_MONTH = 2;
DATA COUNT;
START_DATE = MDY(&STARTING_MONTH.,1,&STARTING_YEAR.);
END_DATE = MDY(&ENDING_MONTH.,1,&ENDING_YEAR.);
COUNT_MONTH = INTCK('MONTH',START_DATE,END_DATE)+1;
COUNT_MONTH_4 = COUNT_MONTH - 4;
COUNT_MONTH_3 = COUNT_MONTH - 3;
call symputx('NUM_MONTH', COUNT_MONTH);
call symputx('NUM_MONTH_4', COUNT_MONTH_4);
call symputx('NUM_MONTH_3', COUNT_MONTH_3);
RUN;
%MACRO FINAL_DATA;
%DO i = 0 %TO &NUM_MONTH_4.;
%LET ADDITION = %EVAL(&i.+3);
%LET TARGET_DB=INTNX('MONTH', MDY(&STARTING_MONTH.,1,&STARTING_YEAR.), &ADDITION., 'SAME');
%LET TARGET_DB_MONTH = MONTH(&TARGET_DB.);
%LET TARGET_DB_YEAR = YEAR(&TARGET_DB.);
%LET DB = %EVAL(&TARGET_DB_YEAR.*100+&TARGET_DB_MONTH.);
LIBNAME TETRIS "/actuary/Commercial/Monthend/&DB.";
%LET TARGET_EFF =INTNX('MONTH', MDY(&STARTING_MONTH.,1,&STARTING_YEAR.), &i., 'SAME');
%LET TARGET_EFF_MONTH = MONTH(&TARGET_EFF.);
%LET TARGET_EFF_YEAR = YEAR(&TARGET_EFF.);
%EXTRACTION(INFORCE, &TARGET_EFF_YEAR.,&TARGET_EFF_MONTH.);
%END;
%DO j = &NUM_MONTH_3. %TO &NUM_MONTH.;
%LET DB = %EVAL(&ENDING_YEAR.*100+&ENDING_MONTH.);
LIBNAME TETRIS "/actuary/Commercial/Monthend/&DB.";
%LET TARGET_EFF =INTNX('MONTH', MDY(&STARTING_MONTH.,1,&STARTING_YEAR.), &j., 'SAME');
%LET TARGET_EFF_MONTH = MONTH(&TARGET_EFF.);
%LET TARGET_EFF_YEAR = YEAR(&TARGET_EFF.);
%EXTRACTION(INFORCE, &TARGET_EFF_YEAR.,&TARGET_EFF_MONTH.);
%END;
%MEND;
%FINAL_DATA;
I am new to SAS. Any advice would be greatly appreciated.
Thank you.