SAS - 数据集去掉重复值和得到重复值
用 PROC SORT 步的参数 nodupkey 和
dupout
分别得到去重之后的数据集,和重复值组成的数据集。
假设数据集A为:
ID age sex win lost
1 20 F 200 120
2 22 M 150 130
2 22 M 150 80
3 25 M 110 90
3 25 M 110 210
4 27 F 105 85
proc sort data=A out=B dupout=C nodupkey; By ID age sex win; run;
上面 code 得到在 ID*age*sex*win level 去重后的 dataset B :
ID age sex win lost
1 20 F 200 120
2 22 M 150 130
3 25 M 110 90
4 27 F 105 85
和重复值 dataset C :
ID age sex win lost
2 22 M 150 80
3 25 M 110 210
参考:Solved: proc sort and dupout: how to get the pairs of dupl... - SAS Support Communities