Have you tried the decode function? This works in Oracle, but have not tested in proc sql, but should be something along these lines: proc sql; create table all_cpt_values as select distinct a1.id, a1.claim_id, a1.icd9, max(decode(b1.cpt = /*Value for CPT_1*/, 1)) as cpt_1, max(decode(b1.cpt = /*Value for CPT_2*/, 1)) as cpt_2 from ( select a.id, a.claim_id, a.icd9 from table_a a ) a1, ( select b.id, b.claim_id, b.cpt from table_b b ) b1 where a1.id = b1.id and a1.claim_id = b1.claim_id; group by a1.id, a1.claim_id, a1.icd9 quit;
... View more