xuanyue
xuanyue

Reputation: 1428

SAS Merge two dataset with same variable name

I have the following program which merge two observations, but with same column name (variable), I want to know why in the merge result column A get dropped?

data three;
     merge one(in=a) two;
     by ID;     
run;

enter image description here

Upvotes: 2

Views: 3113

Answers (1)

Tom
Tom

Reputation: 51566

You should get a note in the log telling you why.

WARNING: The variable a exists on an input data set and is also set by an I/O statement 
         option.  The variable will not be included on any output data set and unexpected
         results can occur.

Don't use the IN= dataset option if you don't need it. Or make sure not to use a name that is already a variable in the dataset.

data three;
  merge one(in=in1) two;
  by ID;
  if in1;
run;

Upvotes: 3

Related Questions