抛砖引玉
proc sql;
create table a1 as
select
distinct A.x as cat,
count(A.x) as n,
'x' as id
from a as A
group by a.x
union all
select
distinct a.y as cat,
count(a.y) as n,
'y' as id
from a as A
group by a.y
;
quit;