各位好...我想請問一下以下的問題...
data tmp1;  
input y;
cards;
 5
 10
 13
17
run;
data tmp2 ( drop=s f );
set  tmp1;
s=0; p=1; cal=0;
do _n_= _n_ to 2 by -1;
s=s+1;   f=0.3;  
p=(1-f)**s;
end;
cal=y*p;
run;
proc print data=tmp2;
run;
/*output 後是:::
Obs     y      p       cal
1      5    1.000     5.000
2     10    0.700    7.000
3     13    0.490    6.370
4     17    0.343    5.831
但我想cal 的計算方法是較特別..不知code是如何寫呢?以下就是我想output的結果..
Obs     y      p       cal
1      5    1.000     5.0
2     10    0.700    13.5        (10*1+5*0.7)
3     13    0.490    22.45     (13*1+10*0.700+5*0.490)
4     17    0.343    32.715    (17*1+13*0.700+10*0.490+5*0.343)
十分感謝!!