sas - Data step merge PROC SQL equivalent flagging which table record was found in -
sas - Data step merge PROC SQL equivalent flagging which table record was found in -
i merge 2 info sets follows:
data ds3; merge ds1(in=in1) ds2(in=in2); mrgvar; if in1; if in2 flag=1; run;
if proc sql step instead, how can set "flag" variable above?
proc sql; create table ds3 select a.* ,b.* ,??? ds1 left bring together ds2 b on a.mrgvar=b.mrgvar; quit;
a mutual way utilize table alias bring together variable.
proc sql; create table ds3 select a.* ,b.* ,case when b.mrgvar null 0 else 1 end flag ds1 left bring together ds2 b on a.mrgvar=b.mrgvar; quit;
something effect - if b.mrgvar null/missing it's coming table a. (yes, can separately reference 2 though they're same , combined in result table.)
sas
Comments
Post a Comment