How to remove duplicated records\observations WITHOUT sorting in SAS?

前端 未结 8 1641
孤独总比滥情好
孤独总比滥情好 2021-02-08 14:21

I wonder if there is a way to unduplicate records WITHOUT sorting?Sometimes, I want to keep original order and just want to remove duplicated records.

I

8条回答
  •  感情败类
    2021-02-08 14:47

    Depending on the number of variables in your data set, the following might be practical:

    data abc_nodup;
       set abc;
       retain _var1 _var2 _var3 _var4;
       if _n_ eq 1 then output;
       else do;
          if (var1 eq _var1) and (var2 eq _var2) and
             (var3 eq _var3) and (var4 eq _var4)
             then delete;
          else output;
       end;
       _var1 = var1;
       _var2 = var2;
       _var3 = var3;
       _var4 = var4;
       drop _var:;
    run;
    

提交回复
热议问题