Hi All, I am new to SAS and need help with subtracting months from a macro variable storing date in YYYYMM format. I tried the following code but it isn't working, any help on this would be appreciated. The desired value for last_mon is 201909 %let score_month = 201910; /*YYYYMM format */
%let mon_var = %sysfunc(inputn(putn(&score_month,6.)!!'01',yymmdd8.)); /*converting to sas date format by adding day as 01 */
%let last_mon = %sysfunc(intnx(month,&mon_var,-1),yymmn6.); /*subtracting 1 month */
%put &score_month***&last_mon*** Notes : 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 %let score_month = 201910; /*YYYYMM format */ 74 %let mon_var = %sysfunc(inputn(putn(&score_month,6.)!!'01',yymmdd8.)); /*converting to sas date format by adding day as 74 ! 01 */ WARNING: Argument 1 to function INPUTN 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. 75 %let last_mon = %sysfunc(intnx(month,&mon_var,-1),yymmn6.); /*subtracting 1 month */ 76 %put &score_month***&last_mon***; 201910***.*** 77 78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 90
... View more