BadKarma1122
BadKarma1122

Reputation: 87

Syntax error for WHERE clause when using proc sql

I am new to SAS and I need to recreate a query I had running using R. The syntax rules may be different in SAS but I dont see where I am going wrong here

Table "Old" columns: A, B, C, D, E

Table "New" columns: A, B, C, D, E

PROC SQL;
                create table delta as
                SELECT *
                FROM New
                WHERE
                (A, B, C)
                IN(
                SELECT (A, B, C)
                FROM New
                EXCEPT 
                SELECT A, B, C
                FROM Old);

QUIT;

My code should find delta rows based on A, B, C variables.

Error Message on comma

WHERE(A, B, C): ERROR 79-322: Expecting a (.

Upvotes: 1

Views: 332

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

I'm not in sas but could be that this db don't allow the use of tuple in WHERE IN clause.

in this case you could try refactoring your quesry as an inner join

  SELECT *
  FROM New N 
  INNER JOIN  (
      SELECT A, B, C
      FROM New
      EXCEPT 
      SELECT A, B, C
      FROM Old
  ) T ON  T.A  = N.A 
        AND T.B  = N.B  
          AND T.C = N.C 

Upvotes: 1

Related Questions