Ошибки SAS Spool с маскировкой строки - PullRequest
0 голосов
/ 05 сентября 2018

Это сводит меня с ума сейчас. Я пытаюсь замаскировать все специальные символы в определенной строке файла плана 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'>

Спасибо

1 Ответ

0 голосов
/ 05 сентября 2018

Не знаю, почему вы думаете, что вам нужна маскировка. Возможно, это сложнее, чем я думаю, но это также кажется мне ненужной работой.

Это работает, как и ожидалось, дайте мне знать, как, если это работает для того, что вы пытаетесь сделать.

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'>

...