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

前端 未结 8 1672
孤独总比滥情好
孤独总比滥情好 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:40

    /* Give each record in the original dataset and row number */
    data with_id ;
      set mydata ;
      _id = _n_ ;
    run ;
    
    /* Remove dupes */
    proc sort data=with_id nodupkey ;
      by var1 var2 var3 ;
    run ;
    
    /* Sort back into original order */
    proc sort data=with_id ;
      by _id ;
    run ;
    
    

提交回复
热议问题