Match-merge with duplicate value of BY variable

Reply
N/A
Posts: 1

Match-merge with duplicate value of BY variable

while performing the Merge with duplicate value of BY varibales we found that the values of a Column from one Dataset are assigned to all the records of second dataset. Is their any way that i can avoid this so that if the value are their they can be placed and if the record does not have the value/column it should contain blanks.

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001081414.htm

Attachment
Super User
Posts: 5,426

Re: Match-merge with duplicate value of BY variable

Posted in reply to RajeshPathak

Please share your code, so that we can see which are the BY variables. And which column is that you are having problem with.

Looking at the sample data, I can't see where the value "JDCFC" for LOC should be coming from...?

Data never sleeps
Super User
Super User
Posts: 7,039

Re: Match-merge with duplicate value of BY variable

Posted in reply to RajeshPathak

When doing an 1 to many merge most people want the default behavior of SAS.  This because they are usually doing a lookup of values.

To force SAS to clear the data vector you can use CALL MISSING statement.

Here is a trivial example.

data one;

  input id one @@;

cards;

1 1 1 2 1 3 2 4 2 5 3 6 4 7

run;

data two;

  input id two @@;

cards;

1 11 2 12 3 13 4 14

run;

data want;

  merge one two;

  by id;

  output;

  call missing (of _all_);

run;

Ask a Question
Discussion stats
  • 2 replies
  • 213 views
  • 0 likes
  • 3 in conversation