是否可以将Macro变量放入PROC DB2EXT查询中?
这有效:
WHERE SDD BETWEEN '01.05.2018' AND '30.05.2018'
但是我所有尝试插入Macro变量的尝试都导致错误
宏的声明
/* Statement in SAS, declaring the Macro, and transfering in to the remote session */
%let month = 05;
%SYSLPUT MONTH = &month;
%PUT &MONTH;
DB2EXT SQL
/* Error(-180): DSN00180E THE DATE, TIME, OR TIMESTAMP VALUE 01."&month.".2018 IS INVALID */
WHERE SDD BETWEEN '01."&month.".2018' AND '30.05.2018'
/* Error(-206): DSN00206E 01.MAY.2018 IS NOT VALID IN THE CONTEXT WHERE IT IS USED */
WHERE SDD BETWEEN "01.&month..2018" AND '30.05.2018'
/* Futile attemps */
WHERE SDD BETWEEN '01&month2018' AND '30.05.2018'
WHERE SDD BETWEEN '01month2018' AND '30.05.2018'
答案 0 :(得分:1)
在生成需要包含评估的宏变量的单引号文字时,请使用以下构造:
%str(%')macro-evaluation%str(%')
忽略上述代码的堆栈溢出(SO)着色有些奇怪。 SO渲染器无法解读作为%str()闭包的一部分的单引号
所以你的情况可能是
%str(%`)01&month.2018%str(%')