In some
cases, you might want to find only the unique values in a column.
For example, if you want to find the unique continents in which U.S.
states are located, then you might begin by constructing the following
query:
libname sql 'SAS-library';
proc sql outobs=12;
title 'Continents of the United States';
select Continent
from sql.unitedstates;
Selecting a Column with Duplicate Values
You can eliminate the
duplicate rows from the results by using the DISTINCT keyword in the
SELECT clause. Compare the previous example with the following query,
which uses the DISTINCT keyword to produce a single row of output
for each continent that is in the SQL.UNITEDSTATES table:
libname sql 'SAS-library';
proc sql;
title 'Continents of the United States';
select distinct Continent
from sql.unitedstates;
Eliminating Duplicate Values
Note: When you specify all of a
table's columns in a SELECT clause with the DISTINCT keyword, PROC
SQL eliminates duplicate rows, or rows in which the values in all
of the columns match, from the results.