这让我发疯了。我试图掩盖在网格安装期间使用的SAS计划文件的特定行中的所有特殊字符,这些文件已放入数据集中:
if test_item = %str(<Machine Id=%'$machine:)&mach_num.%str(' Name=')&mach_name.%str(%'>) then end2 = end1;
日志打印在下面。我看到正在出现假脱机错误(可能是因为某些内容未被正确屏蔽),但是日志中的MPRINT
表明宏变量编译已正确执行。
SYMBOLGEN: Macro variable FUNC_VAR resolves to test
MPRINT(PLAN_FINDER): data test_plan4;
SYMBOLGEN: Macro variable FUNC_VAR resolves to test
MPRINT(PLAN_FINDER): set test_plan3;
MPRINT(PLAN_FINDER): by ret_sort;
MPRINT(PLAN_FINDER): retain end2;
388: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 388-185: Expecting an arithmetic operator.
SYMBOLGEN: Macro variable MACH_NUM resolves to 2
SYMBOLGEN: Macro variable MACH_NAME resolves to Metadata Server
76: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 76-322: Syntax error, statement will be ignored.
________
49
MPRINT(PLAN_FINDER): if test_item = <Machine Id='$machine:2' Name='Metadata Server'> then end2 = end1;
MPRINT(PLAN_FINDER): else if end1 = 1 then end2 = end1 + end2;
MPRINT(PLAN_FINDER): run;
有人可以告诉我我做错了什么吗?
代码:
%macro test(func_var, mach_num, mach_name);
data &func_var._plan4;
set &func_var._plan3;
by ret_sort;
retain end2;
if test_item = %str(<Machine Id=%'$machine:)&mach_num.%str(' Name=')&mach_name.%str(%'>) then end2 = end1;
else if end1 = 1 then end2 = end1 + end2;
run;
%mend;
%test(test, 2, Metadata Server);
test_item
中字符串的预期解析度:
<Machine Id='$machine:2' Name='Metadata Server'>
谢谢
答案 0 :(得分:3)
我不知道您为什么认为您需要掩蔽。这可能比我想的要复杂,但对我来说似乎也有很多不必要的工作。
这对我来说是预期的工作,请让我知道它是否可以用于您要尝试的工作。
test_item = "<Machine Id='$machine:&mach_num.' Name='&mach_name'>"
在数据步骤中进行测试:
%let mach_name=Metadata Server;
%let mach_num=2;
data test;
test_item = "<Machine Id='$machine:&mach_num.' Name='&mach_name'>" ;
run;
proc print data=test;
run;
结果:
test_item = <Machine Id='$machine:2' Name='Metadata Server'>