SAS has some very powerful ways to find duplicate values and to store the duplicates separate from the unique values. Many of these use the sort procedure. Here is a nice guideline for what would otherwise be very difficult to figure out on your own.
Eric Cai. Separating Unique and Duplicated Observations Using PROC SORT in SAS 9.3 and Newer Versions. The Chemical Statistician blog, April 10, 2015. Available in html format.