是这个意思?
proc sql;
create table step1 as
select * from test
where y ne . or x in (select y from test where y ne .);
create table step2 as
select distinct y from test
group by y
having y ne . and (count(*)>1 or y in (select x from step1 where y ne .));
create table wanted as
select * from step1
union all
select y as x, . as y from step2
order by x;
quit;
|