Hi Robby, Some usefull answers provided, here is something alse as well: *You could use the actual date; %let edateset=%sysfunc(putn("01Sep2011"d, 8.)); *Or the SAS data you provided; %let edateset=18871; %macro exclude(count); %local x; %do x=1 %to &count; %let e&x.monthago = %sysfunc(intnx(month,&edateset.,-&x.)); *you need to use && to resolve the macro name after the numeric has been resolved. *the macro processor will first resolve all values with a single &, e.g. &x. and double &'s will resove to a single &, *thus the first resolution will give &e1monthago. This is the actual variable name that you are looking for finally; %put &&e&x.monthago; %end; %mend exclude; %exclude(6); *COMPLETE SOLUTION; *For the where clause you could use; %macro exclude(count); %local x; *this will initialise the vairable and global it, but we want to clear it in case we run it more than once; %global whrein; *clear the variable; %let whrein=; %do x=1 %to &count.; %let e&x.monthago = %sysfunc(intnx(month,&edateset.,-&x.)); *add the assigned variable to the string; %let whrein=&whrein &&e&x.monthago; *add a comma for the where clause if it is not the final value; %if %eval(&x. ne &count.) %then %let whrein=&whrein,; %end; *you can also add the baarckets here, or later in the where clause; %let whrein=(&whrein.); %put &whrein.; %mend exclude; %exclude(6);
... View more