求助, sas如何一对一匹配
比如我有两组数据, 一组控制组一组处理组, 要求的是对于处理组的每一个样本,选择控制组中年龄相同,体重差异最小的作为匹配对象,这种应该怎么处理啊?
我使用的方式是proc sql, 具体代码如下
PROC SQL;
CREATE table controls_id
as select
one.id as treat_id,
two.id as control_id,
one.age as treat_age,
two.age as control_age,
one.weight as treat_weight,
two.weight as control_weight,
abs(one.weight - two.weight) as diff
from treat one, control two
where ( one.age=two.age )
group by one.id having calculated diff = min(calculated diff);
run;
麻烦各位大神帮我看一下,谢谢!