更新时间:2023-02-18 13:04:35
最简单的方法是在 merge
语句中使用 keep
选项.
The simplest way is to use the keep
option on your merge
statement.
data result;
merge table_1 (in=a) table_2 (in=b keep=id definition);
by id;
if a;
run;
另一种意味着您不必对数据集进行排序的方法是使用 proc sql.
An alternative that means you don't have to sort your datasets is to use proc sql.
proc sql;
create table result as
select a.*,
b.definition
from table_1 a
left join table_2 b on a.id = b.id;
quit;
最后,如果 table_2 很小,还有哈希表选项:
Finally, there is the hash table option if table_2 is small:
data result;
if _n_ = 1 then do;
declare hash b(dataset:'table_2');
b.definekey('id');
b.definedata('definition');
b.definedone();
call missing(definition);
end;
set table_1;
b.find();
run;