Reputation: 87
I am asking for a little help. link where is question In above post I have little problem set dynamic variable which I will count used columns. How I can do it?
data want;
set have;
array V varr1-varr3;
call SYMPUTN('countxxx',dim(V)) /* here I try set numeric*/
array L[&countxxx.] _temporary_;/* here input numeric*/
* save first rows values in temporary array for use in other rows;
if _n_ = 1 then
do index = 1 to dim(V);
L[index] = V[index];
end;
* … for example … ;
array delta_from_1st [&countxxx.]; * array statement implicitly creates three new variables that become part of PDV and get output;
do index = 1 to dim(V);
delta_from_1st[index] = V[index] - L[index];
end;
run;
Upvotes: 0
Views: 676
Reputation: 51566
It is not a character vs numeric issue. All macro variables are character, but since your value is all digits the SAS compiler will interpret the text it generates as a number since you are not enclosing it in quotes.
The real issue is that you are trying to reference the macro variable COUNTXXX before you have created it. The macro references are resolved before the data step starts running. Split your step into two steps.
data _null_;
set have;
array V varr:;
call SYMPUTX('countxxx',dim(V)) ;
stop;
run;
data want;
set have;
array L[&countxxx.] _temporary_;
...
Upvotes: 2