Reputation: 641
I am trying to save a value from a varialbe to a macro variable by using
call symputx
however SAS throws error
the program i wrote is this way
data want;
set have;
array SR(*) &orde;
bb=dim(SR);
call symputx('D',bb);
array M(symget('D'));
do i=1 to dim(SR);
M(i)=SR(i);
end;
run;
it gives error as
array MXY_A(symget(D));
-
79
76
ERROR 79-322: Expecting a ).
ERROR 76-322: Syntax error, statement will be ignored.
what could possibly be wrong here?
Upvotes: 0
Views: 136
Reputation: 1804
The code below iterates through each value of the array then outputs it in a new row in the WANT dataset:
Code:
data want(keep=id new);
array score{3} s1-s3;
/*array values: 99,60,82 */
input id score{*};
do i=1 to dim(score);
new=score{i};
output;
end;
datalines;
1234 99 60 82
;
run;
Output:
Upvotes: 0
Reputation: 9569
The dimensions of an array are set during the compilation of the data step, before it starts executing. Defining macro variables via call symput
doesn't happen until the data step starts executing. If you want to use a macro variable to set the size of an array like this, you need to define it prior to your data step.
Upvotes: 2