@Cho8 wrote: @Ksharp wrote: Do you have SAS/IML ? I would like to use IML code for this kind of question. data have;
input y $ d1-d9;
datalines;
201201 0.01 0.00 0.01 0.00 0.00 0.00 0.01 0.01 0.01
201202 0.03 -0.01 0.02 0.01 0.00 0.00 0.01 0.00 0.04
201203 0.01 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.02
201204 0.02 0.01 0.00 0.01 0.02 0.00 0.00 0.00 0.01
201205 0.01 0.00 0.00 0.02 0.00 0.00 0.01 0.00 0.03
201206 0.00 0.01 0.01 0.02 0.00 0.00 0.00 0.00 0.01
201207 0.01 0.02 0.00 0.00 0.00 0.00 0.03 0.00 0.02
201208 0.01 0.00 0.00 0.01 0.01 0.00 0.02 0.02 0.00
201209 0.01 0.01 0.00 0.03 0.00 0.02 0.01 0.00 0.02
201210 0.02 0.00 0.00 0.01 0.04 0.03 0.02 0.01 0.04
201211 0.01 0.02 0.01 0.00 0.00 0.00 0.00 0.03 0.00
201212 0.02 0.00 0.01 0.00 0.01 0.06 0.00 0.02 0.03
201301 0.02 0.02 0.00 0.00 0.00 0.00 0.00 0.00 0.02
201302 0.00 0.00 0.01 0.00 0.00 0.01 0.00 0.01 0.05
201303 0.01 0.01 0.00 0.01 0.00 0.01 0.00 0.01 0.00
201304 0.00 0.04 0.01 0.01 0.01 0.03 0.02 0.04 -0.01
;
proc transpose data=have out=temp name=y prefix=_;
var d1-d9;
id y;
run;
data temp;
set temp;
array x{*} _:;
count=0;
do i=1 to 13;
n=_n_+i;
if n>dim(x) then leave;
count+1;
sum=sum(sum,x{n});
end;
_avg=sum/count;
drop i n count sum;
run;
proc transpose data=temp out=want;
var _:;
id y;
run;
i dnt have SAS IML.. Need solution in Datastep or Macro i didnot get the logic of array part..can you just explain it..
... View more