10-29-2011 09:11 AM
I try to use array in Maro, but problem occurs with dim, here it is,
array a(*) _numeric_;
%do i= 1 %to dim(a);
SAS shows it can not find the operator in expression: dim(a).
Can someone please help. Thanks!
10-29-2011 10:35 AM
The macro language is processes before the generated code is run by SAS. So you cannot reference the value of a data step variable or function like DIM(). But you do not need macro language for what you are doing. Just use a normal data step DO loop instead.
The only need for macro logic in your program would be to set the dimensions of the B array. You could possibly just set an upper bound and create more variables than you need.
Are you planning to create NEW variables with that array? Are you sure that none of the variables in dataset A look like B1, B2, etc that your ARRAY statement will generate? If they do then you will be referencing the same variable in both the A and the B array.
array a _numeric_;
if dim(a) > &maxdim then abort;
do i= 1 to dim(a);