[英]SAS calulations with multiple observations
我正在尝试计算观察值。 我的数据看起来像
ID LAND DECILE DISTANCE
1 85 1 1.5
1 85 2 3.4
.
.
1 85 9 13.2
2 76 1 0.9
2 76 2 2.7
我正在尝试为每个ID用十个十分位数计算(decile10 - decile(i+1))/(decile10 - decile1)
,其中i是第i个位数。 我不担心十进制。谢谢您的帮助! 一整天都在努力。
在数据集上获取多个事物的简单方法:合并。 在这里,我们合并了10等分到所有10个十分位,并使用retain
,以保持第一等分值。 如果排序很困难,还有其他方法可以使用,但是如果您的数据不是很大,这是最简单的方法。
proc sort data=have;
by id decile;
run;
data merged;
merge have have(where=(decile=10) rename=(distance=distance_10 decile=decile10) keep=id decile distance);
by id;
retain distance_1;
if first.id then distance_1=distance; *assuming sorted by ID then decile;
... your calculations, using distance_1 and distance_10 ...
run;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.