SAS:加入更新?

时间:2017-08-22 17:26:52

标签: 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;

我正在处理百万条记录。我必须使用join,但我无法使用。

1 个答案:

答案 0 :(得分:0)

您不需要加入,只需使用相关子查询。

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;