【发布时间】:2017-03-20 20:43:14
【问题描述】:
我在 SAS 中运行这个 sql 宏。
%macro calc(table=,cut=,whereclause=);
proc sql;
&table
select
&cut as type format = $40. length = 40
,dt
,count(prod_nbr) as stat
,sum(new) as new
,sum(old) as old
,sum(retired) as retired
,sum(replaced) as replaced
,sum(final) as final
,sum(redo) as redo
from work.product
where retail_flg = 1
&whereclause
group by 1,2;
quit;
%mend calc;
我在程序中调用了大约 60 次宏,它在我调用它时大约 80% 的时间都在工作。但是每隔一段时间它就会产生这个错误:
ERROR: All positional parameters must precede keyword parameters
如果我以相同的顺序运行代码,错误总是显示在同一行。但是,如果我开始以不同的顺序运行调用,错误最终将出现在看似随机的调用宏的代码行上。下面是其中一个调用的示例(在创建计算表之后):
%calc(table = insert into calc, cut = 'Product', whereclause = and brand = 'JNJ' and Prod_type = 'N' and index(prod_nm, 'NEW') > 0);
我对这个错误特别困惑,因为我在宏中没有任何位置参数。我已经研究并解决了语法错误和其他常见问题,但无法解决错误。
【问题讨论】:
-
你怎么叫它多次?通过其他宏?调用执行?
-
我只是像上面那样运行多行代码。例如: %calc(table = insert into calc, cut = 'Product', whereclause = and brand = 'JNJ' ); %calc(table = insert into calc, cut = 'New Produce', whereclause = and brand = 'WMT' and Prod_type = 'Q');
-
所以你是手动输入的?
-
@Tom 是的。我只使用 SAS 3 个月。这是我知道的唯一方法。
标签: macros sas params-keyword