data have;
input clamnum sno;
datalines;
900001 1
900001 2
900002 3
900003 4
900003 5
900008 6
;
run;
data want;
Not tested:
proc sort data=have out=sorted; by clamnum; run; data want; set sorted; by clamnum; if first.clamnum and last.clamnum; run;
Docs: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/n01a08zkzy5igbn173zjz82zsi1s.htm
View solution in original post
You can create the subset directly from PROC SORT.
data have; input clamnum sno; datalines; 900001 1 900001 2 900002 3 900003 4 900003 5 900008 6 ; run; proc sort nounikey data=have out=dups uniout=unique; by clamnum; run; proc print data=unique; run; proc print data=dups; run;
Interesting, i have never seen the options "nounikey" ... will have to memorise it.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.