[英]Assign a SAS macro variable with quotes to a data step var
How to make below statement works? 如何使以下陈述起作用?
%let qccomment= /n ORACLE execute error: ORA-20001: User xyxlll
does not have acccess to the gva BA_DEV ORA-06512: at
"M_UTIL", line 51 ORA-06512: at line 1. /nTable XY_XY does not exist
(Oracle extract data failed);
%put &qccomment;
data null;
i ="&qccomment";
put i;
run;
It return with error ERROR 386-185: Expecting an arithmetic expression. 它返回错误ERROR 386-185:期望算术表达式。
ERROR 200-322: The symbol is not recognized and will be ignored. 错误200-322:该符号无法识别,将被忽略。
ERROR 76-322: Syntax error, statement will be ignored. 错误76-322:语法错误,该语句将被忽略。
You can use the SYMGET() function to retrieve the value a macro variable without having to worry about any macro quoting (at least in the step that is doing the retrieval). 您可以使用SYMGET()函数来检索宏变量的值,而不必担心任何宏引用(至少在进行检索的步骤中)。
data _null_;
i = symget('qcomment');
put i= ;
run;
If you really did need to reference the macro variable's value and use it to generate a quoted string then use the QUOTE() function to insure that any embedded quotes are properly doubled so that the generated string is a valid string literal. 如果确实需要引用宏变量的值并使用它来生成带引号的字符串,则可以使用QUOTE()函数来确保将任何嵌入的引号正确加倍,以使生成的字符串是有效的字符串文字。
data _null_;
put %sysfunc(quote(&qcomment));
run;
You need to use macro quoting function to get around this, 您需要使用宏引号功能来解决此问题,
/* Using %BQUOTE in let statement to quote the string */
%let qccomment= %bquote(/n ORACLE execute error: ORA-20001: User xyxlll
does not have acccess to the gva BA_DEV ORA-06512: at
"M_UTIL", line 51 ORA-06512: at line 1. /nTable XY_XY does not exist
(Oracle extract data failed));
%put &qccomment;
data null;
i ="&qccomment";
put i;
run;
LOG LOG
11 %let qccomment= %bquote(/n ORACLE execute error: ORA-20001: User xyxlll
12 does not have acccess to the gva BA_DEV ORA-06512: at
13 "M_UTIL", line 51 ORA-06512: at line 1. /nTable XY_XY does not exist
14 (Oracle extract data failed));
15
16 %put &qccomment;
/n ORACLE execute error: ORA-20001: User xyxlll does not have acccess to the gva BA_DEV
ORA-06512: at "M_UTIL", line 51 ORA-06512: at line 1. /nTable XY_XY does not exist
(Oracle extract data failed)
17 data null;
18 i ="&qccomment";
19 put i;
20 run;
/n ORACLE execute error: ORA-20001: User xyxlll does not have acccess to the gva BA_DEV
ORA-06512: at "M_UTIL", line 51 ORA-06512: at line 1. /nTable XY_XY does not exist
(Oracle extract data failed)
NOTE: The data set WORK.NULL has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.08 seconds
cpu time 0.00 seconds
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.