In a Left Join, I may have missing values that I would like to default to some specific string. I can't seem to determine when the Right table is not contributing observations. In the following code, I want a table that looks like: k1 aa bb gg hh k2 cc dd XX YY <==== defaulted data since no k2 value in right table k3 ee ff ii jj Reading posts from this community, I think I want to use the CASE WHEN DO END sequence of statements but I can't seem to code them correctly - or if my test of IS NULL is correct. data file1;
input key1 $
var1 $
var2 $;
datalines;
k1 aa bb
k2 cc dd
k3 ee ff
;
data file2;
input key2 $
var3 $
var4 $;
datalines;
k1 gg hh
k3 ii jj
;
proc sql ;
create table file3 as
select a.key1,
a.var1,
a.var2,
b.var3,
b.var4
case when b.key2 is null then
do ;
b.var3 = 'XX' ;
b.var4 = 'YY' ;
end ;
from file1 as A left join
file2 as B
on a.key1 = b.key2 ;
... View more