考虑这个示例,其中所选值具有特殊的宏字符&和%影响分辨率。CCD_ 1用于屏蔽字符。
data have;
id=1; s='A&B %now';
proc sql noprint;
select s into :myvar from have where id=1;
%put &=myvar;
%put &myvar;
%let myvar = %superq(myvar); /* macro quote the special symbols & and % */
%put &=myvar;
------------------- LOG -------------------
53 proc sql noprint;
54 select s into :myvar from have where id=1;
55
56 %put &=myvar;
WARNING: Apparent symbolic reference B not resolved.
WARNING: Apparent invocation of macro NOW not resolved.
MYVAR=A&B %now
57 %put &myvar;
WARNING: Apparent symbolic reference B not resolved.
WARNING: Apparent invocation of macro NOW not resolved.
A&B %now
58
59 %let myvar = %superq(myvar); /* macro quote the special symbols & and % */
60
61 %put &=myvar;
MYVAR=A&B %now
是否存在强制宏引用所选值的SELECT <expression> INTO :<symbol>
语法?
否。
在SELECT之后添加%LET语句。
proc sql noprint;
select s into :myvar from have where id=1;
%let myvar=%superq(myvar);
或者添加实际的引号字符。
proc sql noprint;
select quote(trim(s),"'") into :myvar from have where id=1;