SAS:使用加入进行更新?

  • 本文关键字:更新 SAS sql sas
  • 更新时间 :
  • 英文 :


我正在尝试从表test_ctrl.control_s更新test1.control_s的值。

我正在使用以下代码:

proc sql;
update test1
set control_s= (select control_s 
from test_ctrl
inner join test1
on test1.custno=test_ctrl.custno
and test1.accno=test_ctrl.accno);
quit;

我正在处理数百万条记录。我必须使用加入,但我不能。

你不需要加入,你只需要使用一个相关的子查询。

proc sql;
update test1
set control_s= (select control_s 
from test_ctrl
where test1.custno=test_ctrl.custno
and test1.accno=test_ctrl.accno);
quit;

下面是一个使用sashelp.class的示例:

data class;
set sashelp.class;
height=0;
run;
data ht_data;
set sashelp.class;
keep name height;
run;
proc sql;
update class
set height = (
select height from ht_data
where ht_Data.name = class.name
);
quit;

最新更新