So try using this for your macro variables: %let date=01Jun2015; %let ostart=%sysfunc(intnx(month,"&date"d,-19,B),date9.); %let oend=%sysfunc(intnx(month,"&date"d,-1,E),date9.); Then when you call them, I would call them like this: original_purchase_date between "&ostart"d and "&oend"d. For the datepart() function, I don't believe SQL Language knows what it is, and since you're connecting into the Oracle database, you probably can't use it. I do a differen't way of pulling my data from Oracle (through a libname statement). I would look into the convert() function in SQL and see if you can try something that way, I'm not exactly sure if SAS will like that or not, but I know that's a SQL language way to convert() variables.
... View more