相乘变量的总和

时间:2019-01-22 11:30:58

标签: sas sas-macro

我需要从R cran的“过滤器”下转换为SAS:

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

我在SAS中的代码:

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

0 个答案:

没有答案
相关问题