## comparing two column

Solved
Regular Contributor
Posts: 225

# comparing two column

hi all -

i have two variable 'a' and 'b'. 'a' has 33092 and 'b' has 35760 observation. some observation are matching in both and some are not.

i wants to create new variable 'c' which has same observation from both 'a' and 'b' (i mean matching from both variable 'a' and 'b') variables and

new variable 'd' which has observation from 'b' but doesn't has observation from 'a'

Accepted Solutions
Solution
‎04-15-2013 03:17 PM
Posts: 5,624

## Re: comparing two column

You mean something like this?

data want;

set have;

if a = b then c = a;

else d = b;

run;

PG

PG

All Replies
Solution
‎04-15-2013 03:17 PM
Posts: 5,624

## Re: comparing two column

You mean something like this?

data want;

set have;

if a = b then c = a;

else d = b;

run;

PG

PG
Regular Contributor
Posts: 225

## Re: comparing two column

thanks PG!

Regular Contributor
Posts: 225

## Re: comparing two column

Hi PG i have one more q if you can answer me...,.

have same 'a' and 'b' variable

a                    b

01001      01001

01002      01002

01004      .

01005      01005

01021      .

in outout i want only 01004,01021 - how can i get that...

Thank You...

Posts: 5,624

## Re: comparing two column

If I understand your request, you can get the list of cases where b is missing as a dataset with:

data want;

set have; where b is missing;

keep a;

run;

If you just want to print the cases:

proc print data=have(where=(b is missing)); var a; run;

PG

PG
Regular Contributor
Posts: 225

## Re: comparing two column

Thanks you so much for your help PG!