Proc SQL 可以使选择的 INTO 宏变量的值被宏引用吗?
Can Proc SQL cause the value selected INTO a macro variable to be macro quoted?
考虑此示例,其中所选值具有影响分辨率的特殊宏字符 & 和 %。 %superq()
用于屏蔽字符。
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;
考虑此示例,其中所选值具有影响分辨率的特殊宏字符 & 和 %。 %superq()
用于屏蔽字符。
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;