SAS Proc SQL, combine where, left join and case
<p>I have three piece of code. How can I combine them into one so that they look elegant? data1: pull data with some condition; data2: data1 left join new data; data3: set to data2 and create a new variable.</p>

<pre><code>proc sql; create table data1 as select
a.ID,
b.decison_CD,
c.type,

from
dataA  a,
dataB  b,
dataC  c,

where a.ID=b.ID
and   a.ID=c.ID
and   c.type not in ('Unknown')
and   b.decison_CD in (‘Y’,’N’)
; quit;


proc sql;
create table data2 as select 
a.*
,b.payId

from data1 a
left join datanew b
on a.ID=b.ID;
quit;

data data3;
set data2;
if payID= . then booked =0;
else if payID=1 then booked=1;
run;
</code></pre>