2

Last time I checked, this is completely legit SQL code that even Access can handle. Not sure why I'm getting the following error from SAS

UPDATE fu_coding 
INNER JOIN old_form16 
    ON fu_coding.CSPCCID = old_form16.CSPCCID 
SET fu_coding.CHANGED = 1
WHERE fu_coding.NEW_DIAG <> old_form16.NEW_DIAG;

Error is:

18311      INNER JOIN old_form16
           -----
       22
       76
ERROR 22-322: Syntax error, expecting one of the following: a name, (, '.', AS, SET.
ERROR 76-322: Syntax error, statement will be ignored.

I really appreciate your help with this!

blacksaibot
  • 265
  • 2
  • 12

2 Answers2

3

I don't think proc sql supports update with inner join. You can do this:

UPDATE fu_coding 
    SET CHANGED = (SELECT 1
                   FROM old_form16
                   WHERE fu_coding.CSPCCID = old_form16.CSPCCID AND
                         fu_coding.NEW_DIAG <> old_form16.NEW_DIAG
                  )
    WHERE EXISTS (SELECT 1
                   FROM old_form16
                   WHERE fu_coding.CSPCCID = old_form16.CSPCCID AND
                         fu_coding.NEW_DIAG <> old_form16.NEW_DIAG
                  ) ;

The code might be simpler using a data step.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

SAS doesn't support update with inner join in the SQL procedure. Either re-write (as per @Gordon's suggestion), or use pass through if possible!

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124