Removing duplicate records

There are several ways to get rid of duplicate records in SAS. The examples below are for records that are exactly alike. If you need to get rid of records that have duplicate IDs, see Removing records with duplicate IDs.

First/Last Method - Retains first or last record and deletes duplicates

proc sort; by id;
data h;
   set input;
   by id;
if first.id;
proc print;
var id h;

In the above case, 'last.id' can be used in place of 'first.id.'

Option Method - option in PROC SORT for duplicates

proc sort noduprec; by id;
proc print;
var id h;

NEW PSC blog

Recent resources, events, news

New Publications

Knodel et al. "Gendered Housework in Vietnam." PSC Research Report.

Couper. Designing Effective Web Surveys

Next Brown Bag

Monday, Oct 13
Jamie Jones
"Fertility & Risk Aversion on Utah Frontier"


W A R N I N G

If you are reading this, it may be that you are using rather old web browsing software that does not support modern international Web technology standards. For a better experience of the Web and this site in particular, please upgrade your web browser software today. The following are good choices: Firefox 2; Opera 9; Safari 3.