用 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