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.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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