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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Submit your idea!
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.