If you're only looking to extract the classes that appear multiple times, you could use something like this:
proc sql;
create table output as
select
a.class, a.id
from
work.test a
inner join
(
select distinct
b.class,
count(b.class) as class_count
from
work.test b
group by
b.class
having
calculated class_count > 1
) c
on
a.class = c.class
order by
a.class, a.id
;