%macro trend;
data gold_dl;
set gold_ds;
%do i = 1 %to 133;
%if c&i>0 %then d&i=1;
%if c&i<0 %then d&i=-1;
%else d&i=0;
%end;
run;
%mend;
%trend;
代码如上,为什么这个循环会报错!而以下代码就正确运行?一直在宏的逻辑判断中出错,if then好像很难在宏中使用啊!头大!希望根据变量符号设置一个新的逻辑变量,求高手醍醐灌顶!
data gold_dl;
set gold_ds;
if c1>0 then d1=1;
if c1<0 then d1=-1;
else d1=0;
run;
报错如下:
NOTE: 由宏变量 I 生成行。
1 d133
----
22
ERROR 22-322: 语法错误,期望下列之一: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX,
MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.