我有以下两个数据集,需要第三个数据集作为输出。
ONE TWO
---------- ----------
ID FLAG NUMB
1 N 2
2 Y 3
3 Y 9
4 N 2
5 N 3
9 Y 9
10 Y
OUTPUT
-------
ID FLAG NEW
1 N N
2 Y Y
3 Y Y
4 N N
5 N N
9 Y Y
10 Y N
如果在 TWO.NUMB 中找到 ONE.ID 并且它是 ONE.FLAG = Y 则新变量 NEW = Y 否则 NEW = N
我能够使用 PROC SQL 来做到这一点,如下所示。
proc sql;
create table output as
(
select distinct id, flag, case when numb is null then 'N' else 'Y' end as NEW
from one
left join
two
on id = numb
and flag = 'Y'
);
quit;
这可以在数据步骤/合并中完成吗?