使用 proc sql 更新 [英] update with a proc sql

查看:31
本文介绍了使用 proc sql 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该很简单,但我卡住了

It should be an easy one but I'm stuck

Proc sql; 

UPDATE dicofr 
SET    dicofr.period = correspondance.period 
FROM   dicofr 
INNER JOIN correspondance 
ON dicofr.name_fic = correspondance.name_fic; 

我以为我的更新会完成,但我收到了这个错误.

I was thinking my update would be done but I got this error instead.

271  proc sql;
272  update dicofr
273  set dicofr.period = correspondance.period
           -
           73
           76
ERROR 73-322: Expecting an =.

ERROR 76-322: Syntax error, statement will be ignored.

我试过用 select

proc sql;
SELECT * FROM dicofr INNER JOIN correspondance 
ON dicofr.nom_fic=correspondance.nom_fic;

选择没问题.

怎么会?

我的 SQL 查询不正确吗?我不这么认为...

Is my SQL query not correct? I don't think so ...

已编辑:看来我想做的更新是不可能的.有没有办法用 SAS 语言做我想做的事?

Edited: It seems the update I want to do is not possible. Is there a way to do what I want with SAS language?

推荐答案

出于某种原因,SAS 不支持 UPDATE 语句中的 JOIN.您需要通过嵌套选择来完成.

SAS doesn't support JOINs in an UPDATE statement, for some reason. You need to do it through a nested select.

proc sql;
update tableA A
set var=
  (select var 
  from tableB B 
  where B.id=A.id)
where exists (
  select 1 
  from tableB B
  where B.id=A.id);
quit;

这篇关于使用 proc sql 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆