Update using proc sql

It should be easy, 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 thought my update would be done, but I got this error.

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.

I tried with a direct connection to select

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

The selection is in order.

How did it happen?

Is my SQL query invalid? I do not think so...

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

+4
source share
2 answers

SAS does not support JOINs in an UPDATE statement for any reason. You need to do this through a nested selection.

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;
+9
source

You're wrong. Try something like this: -

UPDATE dicofr INNER JOIN correspondance 
ON dicofr.name_fic = correspondance.name_fic; 
SET dicofr.period = correspondance.period 
WHERE cond....
0
source

Source: https://habr.com/ru/post/1547574/


All Articles