BookmarkSubscribeRSS Feed
rawindar
Calcite | Level 5

Hi all

    I have two datasets.A and B as follows

    A                        B

Eid                       Eid

    1                        3

    2                        4

    3                        5

I need o/p as follows

Eid

1

2

4

5

I dont want value 3 in o/p dataset.Can anybody help me to solve this.

Thanks & Regards

Rawindarreddy

4 REPLIES 4
Haikuo
Onyx | Level 15

data a;

  input v;

  cards;

  1

  2

  3

  ;

  data b;

  input v;

  cards;

  3

  4

  5

  ;

  data want;

  merge a(in=a) b(in=b);

  by v;

  if a and b then delete;

  run;

Haikuo

shivas
Pyrite | Level 9

Hi ,

Try this..

data a;

input no;

cards;

1

2

3

;

run;

data b;

input no;

cards;

3

4

5

;

run;

data c;

merge a(in=a) b(in=b);

by no;

if a ne b ;

run;

Thanks,

Shiva

Haikuo
Onyx | Level 15

Oops, just notice that OP asked in Proc section, so proc sql may be actually needed:

data a;

  input v;

  cards;

  1

  2

  3

  ;

  data b;

  input v;

  cards;

  3

  4

  5

  ;

  proc sql;

  create table want as

  select * from a

  union corr

  select * from b

  except

  (select * from a

  intersect corr

select * from b);

quit;

Haikuo

art297
Opal | Level 21

Since the subject was interview question, I would think that multiple answers would be preferred.  Thus, I would definitely include interleaving (see, e.g., http://www.sascommunity.org/wiki/Tips:Interleaving ).

Plus, it was never mentioned why 3 wasn't wanted, just that it wasn't wanted and not necessarily just because it was in both datasets.  If it was just because its value was three, I would use an if EID ne 3 statement in the code.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 923 views
  • 1 like
  • 4 in conversation