%let ng = 4;
data a1;
set a2;
array cur{&ng} cur1-cur&ng.;
do i = 1 to &ng.;
if (_n_ = (i-1)*5 + 1) then cur[i] = Val;
end;
run;
错误消息
ERROR: Missing numeric suffix on a numbered variable list (cur1-cur).
ERROR: Too few variables defined for the dimension(s) specified for the array cur.
ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
为什么do i = 1 to &ng.
和cur{&ng}
有效但cur1-cur&ng.
会产生错误?
答案 0 :(得分:2)
该代码对我来说很好,但是我遇到了这个问题,我已经使用proc sql into:
或call symput
方法创建了一个宏变量(在本例中为ng),因为这些设置默认长度为8,并使用空格填充值。我怀疑在你的实际代码中,宏变量ng是以这些方式之一创建的。
要解决此问题,请尝试添加%trim
,如下所示。
array cur[&ng.] cur1-cur%trim(&ng.);
您还需要添加end
语句来关闭do
循环。