sql - SAS: Left join works for defined numbers but not for a selected list of numbers -
let's have 3 tables:
data con1; input id age; cards; 11 22 23 32 32 3 14 73 ; run; data con2; input id age; cards; 11 22 23 32 32 3 14 73 15 11 7 15 ; run; data con3; input id height; cards; 11 150 23 180 32 181 14 175 15 149 7 159 ; run;
now want make left join between con2
, con3
rows not in con1
.
proc sql; create table works select * con2 id not in (select id con1); run; proc sql; create table want select a.*, b.height works left join con3 b on a.id=b.id; run;
this works fine, don't fact have needed 2 steps.
so goal in 1 step should somehow this:
proc sql; create table want_fails select a.*, b.height con2 (where=(id not in (select id con1))) left join con3 b on a.id=b.id; run;
and don't understand how resolves in error, when on other hand following statement working fine:
proc sql; create table want_works select a.*, b.height con2 (where=(id not in (11 23 32 14))) left join con3 b on a.id=b.id; run;
here error:
error 22-322: syntax error, expecting 1 of following: quoted string, numeric constant, datetime constant, missing value, -.
error 76-322: syntax error, statement ignored. error: syntax error while parsing clause. error: invalid value option. error: options file work.con2 not processed because of errors or warnings noted above.
so can please tell me i'm overlooking?
i have workaroud create view
prefere solution @user2877959.
proc sql; create view test select * con2 id not in (select id con1); create table want_works2 select a.*,b.height test left join con3 b on a.id=b.id;
you cannot have subquery in where=
dataset option.
does not want?
proc sql; create table want_works select a.*, b.height con2 left join con3 b on a.id=b.id a.id not in (select id con1); run;
Comments
Post a Comment