sas 等于下一行
给个代例,你的主要是对RETAIN 关键词的应
data test;
input t;
cards;
1
3
3
4
6
6
7
5
9
10
;
run;
data test1;
set test;
retain y;
if _n_=1 then y=t;
else do;
f=t-y;
y=t;
end;
drop y;
run;楼上的回答似乎稍微麻烦了点,上一行的数用函数LAG()就行了比如:
data new;
set old;
b= a - lag(a);
run;
data test;
input t;
cards;
1
3
3
4
6
6
7
5
9
10
;
run;
data test1;
set test;
retain y;
if _n_=1 then y=t;
else do;
f=t-y;
y=t;
end;
drop y;
run;楼上的回答似乎稍微麻烦了点,上一行的数用函数LAG()就行了比如:
data new;
set old;
b= a - lag(a);
run;