This may have been answered adequately already but I didn't see any closure... The most direct answer to your question is that you forgot the where clause after the join. proc sql; create table DQ As select case when r.CostCentre ^= d.CostCentredq then 1 else 0 end as WrongCostCentre from data.resources r, valibla.dq_res d where r.apples=d.apples AND r.oranges=d.oranges; quit; If you really just want the rows where WrongCostCentre =1 then add to the where clause, or add the having clause: proc sql; create table DQ As select case when r.CostCentre ^= d.CostCentredq then 1 else 0 end as WrongCostCentre from data.resources r, valibla.dq_res d where r.apples=d.apples AND r.oranges=d.oranges having WrongCostCentre=1; /* Some would consider this an abuse of the having clause */ quit; Of course, if you only want WrongCostCentre=1 rows, you don't need the CASE statement in the query. It would just be another condition in the where clause.
... View more