Link to home
Start Free TrialLog in
Avatar of Lee R Liddick Jr
Lee R Liddick JrFlag for United States of America

asked on

Two Table Compare

I am needing to compare two tables in SAS (using SQL sytax) to find out what records in Table A is in Table B, and if they are not in Table B, then I want to add a column to the query to mark them as 'New'.

PROC SQL;
      create table TableC as
      select a.*, 'New' as Type
      from TableA a
      where a.id not in (select id from TableB);
QUIT;

Obviously my query is currently only getting those records that don't match and creating the new column...but there has to be a way to do this all in one query, or maybe I'm wrong.
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial