Сумма умноженных переменных - PullRequest
0 голосов
/ 22 января 2019

Мне нужно перевести на SAS ниже "фильтра" от R cran:

filter(1:5, f1, method="recursive")
[1]  1  3  6 10 15

эквивалентно:

x[1]
x[2] + f1*x[1]
x[3] + f1*x[2] + f1^2*x[1]
x[4] + f1*x[3] + f1^2*x[2] + f1^3*x[1]
x[5] + f1*x[4] + f1^2*x[3] + f1^3*x[2] + f1^4*x[1]

f1 является целым числом. Я думаю, что я должен использовать взгляд. У вас есть идеи по поводу решения?

Например:

enter image description here

Мой код в САС:

data have;
  input Variable Value;
datalines;
a 1
a 4
a 5
b 6
b 7
b 10

;
run;


data want;
set have;
by Variable;
%let f1=0.5;
 set have (firstobs=2 keep=Value rename=(Value=LEAD1));
 if last.Variable then LEAD1=.;
  if first.Variable then do;
Out=Value*&f1;
end;
Out=LEAD1*&f1+Value*&f1;
run;

Этот код работает !!!: D

...