name date egg change
1 3-1 2
1 3-2 3
1 3-3 5
1 3-4 1
2 3-1 1
2 3-2 3
3 3-1 3
3 3-2 4
3 3-3 2
4 3-1 1
4 3-2 1
5 3-1 5
5 3-1 4
5 3-2 7
5 3-3 3
需要求每个name,date (t)的egg的值 与 date (t-1)的egg的值的差额。例如name 1, date 3-2时的change=3-2=1,
求高手赐教!

|
楼主: addictedtome
|
5067
4
[原创博文] SAS求同一变量下的差值 |
|
已卖:22份资源 副教授 43%
-
|
回帖推荐If I understand it correct, the change is defined within the name block. Here is a sample problem.
data a;
input name date $ egg;
datalines;
1 3-1 2
1 3-2 3
1 3-3 5
1 3-4 1
2 3-1 1
2 3-2 3
3 3-1 3
3 3-2 4
3 3-3 2
4 3-1 1
4 3-2 1
5 3-1 5
5 3-1 4
5 3-2 7
5 3-3 3
;
data b;
set a;
by name;
change=dif(egg);
if first.name then change=.;
run;
proc print; run;
本帖被以下文库推荐
| ||
|
|
| ||
| ||
| ||
加好友,备注cda京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


