@Tom wrote: @mona4u wrote: didn't work Two problems. (1) the format name is really WORDDATE (not sure when SAS started creating format names with more than 7 characters?). (2) The WORDDATE (and also the MONNAME) format add leading spaces which seem to really confuse the %SCAN() function when trying to process in single nested call. So use %Qsysfunc() instead to quote the comma and leading spaces. Then the %SCAN() function works. %let lastmonth=%scan(%qsysfunc(intnx(month,&today,-1),worddate),1); this is what I tried and it works %let lastmonthn1=%sysfunc(intnx(month,%sysfunc(today()),-1),MONNAME.);
... View more