Note: Edited for the single quotes you need.
Let me first provide a solution that works, and then explain why your approach does not work. Use this piece of code instead:
data _NULL_; call symput("expectdate1",cats("'",put(Date(),YYMMDD10.)),"'"); run;
The above code snippet will create your string and then put it in the macro variable expectdate1.
So why did your code not work?
This is because you do not distinguish between SAS functions and SAS macros. put (Date (), YYMMDD10.) are not macro functions (easily distinguishable because they start with a percent sign. β% <-)
So, SAS Macro does not evaluate it and just puts part of the code in your SQL statement, literally.
Now there is something called the% sysfunc function. This is a macro function that will perform a closed normal function. Thus,% sysfunc (Date ()) will be resolved by the SAS macro before setting the macroenddate variable. Note that each function must be enabled by the% sysfunc function, i.e.
%let someVariable = %sysfunc(mean(max(1,3),5)); /*WRONG*/ %let someVariable = %sysfunc(mean(%sysfunc(max(1,3)),5)); /*RIGHT*/
This suggests that this does not work for some SAS functions, and this is one of them. That's why I presented the solution from above: use the data step to prepare it the way you like and write the result in a macro variable.
source share