Thanks all guys. I write own ema function. It is "identical" to the one from Rick's blog; it goes through
a column-count loop, rather than build-in mech. The computation cost might be same anyhow, but not eff. in coding.
proc iml;
start ownema(xema, x, emawt);
xema=j(1,ncol(x));
do i=1 to max(dimension(x));
if i=1 then do;
xema[,i]=x[,i];
end;
else do;
xema[,i]=x[,i]*emawt+(1-emawt)*xema[,i-1];
end;
end;
finish;
ind=1:100;
x1=sin(ind); /*dim=1 100*/
emawt=0.1;
run ownema(x1ema, x1,emawt);
create _Matrix_Own_ema var {"ind" "x1" "x1ema"};
append;
close _Matrix_Own_ema;
run;quit;
proc sgplot data=_Matrix_Own_ema;
series x=ind y=x1;
series x=ind y=x1ema;
run;quit;
proc iml;
use Sashelp.Air;
read all var "date" into t;
read all var "air" into y;
close;
rct=nrow(t);
print rct;
dim=dimension(t);
print dim;
run;quit;
... View more