Reputation: 1537
%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 msg
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.
Why do i = 1 to &ng.
and cur{&ng}
work but cur1-cur&ng.
generates errors?
Upvotes: 1
Views: 1139
Reputation: 7602
That code works fine for me, however I have encountered this problem where I've created a macro variable (in this case ng) with the proc sql into:
or call symput
methods, as these set a default length of 8 and pad the value with spaces. I suspect in your actual code the macro variable ng is being created in one of these ways.
To get around this, try adding %trim
as below.
array cur[&ng.] cur1-cur%trim(&ng.);
You also need to add an end
statement to close the do
loop.
Upvotes: 2