Help using Base SAS procedures

'If A and not B' equivalent in proc sql

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

'If A and not B' equivalent in proc sql

Hi all,

When merging datasets, is there a proc sql equivalent to the 'if a and not b' statement in data steps?

Thank you,
Marco


Accepted Solutions
Solution
‎04-03-2014 11:22 AM
Super User
Super User
Posts: 7,401

Re: 'If A and not B' equivalent in proc sql

Yep, there are a few ways.  One could be:

proc sql;

     create table want as

     select     A.ID

     from       WORK.A A

     left join   WORK.B B

     on          A.ID=B.ID

     where     B.ID is null;

quit;

View solution in original post


All Replies
Solution
‎04-03-2014 11:22 AM
Super User
Super User
Posts: 7,401

Re: 'If A and not B' equivalent in proc sql

Yep, there are a few ways.  One could be:

proc sql;

     create table want as

     select     A.ID

     from       WORK.A A

     left join   WORK.B B

     on          A.ID=B.ID

     where     B.ID is null;

quit;

New Contributor
Posts: 4

Re: 'If A and not B' equivalent in proc sql

You can also do it in SAS if it makes it easier for you.

Proc sort data= a;

by Id;

run;

Proc sort data= b;

by ID;

run;

data abc;

merge a(in=a) b;

by ID;

if a=1;

run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 5533 views
  • 0 likes
  • 3 in conversation