I have the following data set:
data have;
input x10 x22 x13 x64;
cards;
20 10 30 1
;
run;
I want to create four new columns called log_x10
, log_x22
, log_x13
, log_x64
which are the logs of the original columns. I know this is probably a fairly straightforward array, loop process, but I'm fairly new to arrays and can't quite get the syntax. Here is what I have:
data want;
set have;
array var[*] x: ;
do j=1 to dim(var);
logx[j]=log(var[j]);
end;
run;
It won't always be four variables, sometimes less or more. I have the id numbers pulled into a macrolist id=(10,22,13,64)
so can try to use something like that to name.
Ideas? Thanks.