Использование Retain
функциональности.
Вы можете использовать приведенный ниже код в качестве основы для любых итеративных / кумулятивных вычислений.
data have;
input A;
datalines;
1
2
3
;
run;
data want;
set have;
Retain B;
/* If condition to initialize B only once, _N_ is the current row number */
if _N_= 1 then B=0;
B=B+A;
/* put statement will print the table in the log */
put _all_;
run;
Выход:
A=1 B=1 _N_=1
A=2 B=3 _N_=2
A=3 B=6 _N_=3