Hello,
Using PROC EXPAND, I would like to calculate moving averages for different variables.
Specifically, consider some variables (say x, y, and z) for which I would like to calculate some backward moving averages (20 observations) with different names (say mx, my, mz) which require 3 different minimum number of observations (let's say 20, 18 or 16). This COULD be done as follows:
proc expand data = indta out=outdta method=none;
by ID;
convert x = mx20 / transformout=(movave 20 trim 20);
convert y = my20 / transformout=(movave 20 trim 20);
convert z = mz20 / transformout=(movave 20 trim 20);
convert x = mx18 / transformout=(movave 20 trim 18);
convert y = my18 / transformout=(movave 20 trim 18);
convert z = mz18 / transformout=(movave 20 trim 18);
convert x = mx16 / transformout=(movave 20 trim 16);
convert y = my16 / transformout=(movave 20 trim 16);
convert z = mz16 / transformout=(movave 20 trim 16);
run;
This doesn't sound as a difficult question, but am struggling to create a more flexible solution. I hope someones knows how to automate this, for instance with the following input arguments:
%let indta = indata;
%let outdta = outdata;
%let estdays = 20;
%let mindays = 20 18 16;
%let VarIn = x y z;
%let VarOut = mx my mz;
thanks
Sjoerd
Message was edited by: Sj03rd
Message was edited by: Sj03rd