Hi All, I have a base program that I'm converting to a DI job for automation. Currently in the base job we hard code (and therefore have to manually amend the months) the month folders searched for data compilation. The first thing to note is that the folder names are in 'Month Year' format so 'August 17'. I have already worked out statements to produce this format for the current month and previous month. %let sysmonth= %sysfunc(TODAY(),MONNAME); %let sysyear= %sysfunc(TODAY(),YEAR2.); %let lastmonth= %sysfunc(intnx(month,%sysfunc(TODAY()),-1,e),MONNAME); %let currentmonth= &sysmonth &sysyear; The problem i currently have is programing a macro to read the current month and where this is January make the &lastmonth equal to December of the previous year. I have tried various statements and versions of If and Where but have had no luck. The most recent version of my macro is below and any help would be appreciated. ( in the example i'm using September as the trigger month for testing purposes. %let sysmonth = %sysfunc(TODAY(),MONNAME); %Macro endofyear; %IF &sysmonth = "September", %THEN %let sysyear = /*%sysfunc(intnx(year,%sysfunc(TODAY()),-1,e),YEAR2.)*/ %sysfunc(intnx(year,%sysfunc(&sysyear),-1,e),YEAR2.); %Else; %let sysyear = %sysfunc(intnx(year,%sysfunc(TODAY()),YEAR2.); %run; %mend endofyear; %put &sysmonth; %put $sysyear;
... View more