Hi Adnan,
Another similar reply, in slightly different words (written in parallel to the other replies) ...
First of all, you are talking about macro variables. Macros are something else.
Macro variables store text. As you can see from the results of your %PUT statements, macro variables StartDate and EndDate contain exactly what you've entered before. Nothing has been evaluated.
The macro variable references &Enddate and &StartDate in your WHERE statement will not be resolved (i.e. replaced by the content of the respective macro variable) because they are enclosed in single quotes and therefore treated as text. But even if they were resolved (e.g. if you had used double quotes), you would receive error messages because the resulting expressions would look like "intnx('month', today(),-1, 'end')"d and "'31oct2015'd"d, both of which are invalid.
The easiest way to correct your code is to use the values of the macro variables as they are in the WHERE statement:
where CreatedOn<=&Enddate and CreatedOn>=&StartDate;
Please note that the evaluation of TODAY() will then occur when the WHERE statement is executed. If you let %SYSFUNC or a data step evaluate it already in the definition of macro variable Enddate, the results may be different if that definition and the WHERE statement are not executed on the same day.
... View more