I do not know all the column names of data1, data2, temp1 and temp3 so I have to assume that
commercial_grade and lab_grade also present in data1 table.
You also need to correct the select clause,enter the column name in select clause as you needed in final table temp4
proc sql; create table temp4 as select a.*,b.*, case when c.lab_grade is null then 'N/A' else c.lab_grade end as lab_grade, case when d.commercial_grade is null then 'N/A' else d.commercial_grade end as commercial_grade from data1 a left join data2 b on a.id=b.id and a.regiment_number=b.regiment_number and a.serial_number=b.serial_number left join temp1 c on a.lab_grade= c.lab_grade left join temp3 d on a.commercial_grade = d.commerical_grade; quit;
EDIT: Added comma after lab_grade - PG
... View more