DATA Step, Macro, Functions and more

Merging Error

Occasional Contributor
Posts: 19

Merging Error

I am trying to combine three SAS data files using merge command using the following code.


proc sort data=orion.merger;
by ParcelNumber;

proc sort data=orion.merger1;
by ParcelNumber;
proc sort data=orion.merger2;
by ParcelNumber;

Data orion.mergermain;
merge orion.merger orion.merger1 orion.merger2;
by ParcelNumber;


I have attached a screenshot of the log


Posts: 8,169

Re: Merging Error

Posted in reply to ayushupadhyay22

You have to do a proc contents on the three files and see how the variables are defined in each file.


Where they conflict, if they are just duplicate values (but stored in a different data type) you can drop them (using the drop option) when using the merge statement (e.g., merge orion.whatever (drop=varxx varyyy) )


Art, CEO,


Super User
Posts: 23,778

Re: Merging Error

Posted in reply to ayushupadhyay22

Are you sure you want a merge? Usually merges don't have the same variables in each dataset, or if they do, you need to rename the variables so they're unique in the final data set. You can't have multiple variables with the same name. 


I think you may want to concatenate/append the data instead. You'll have the same issue though, variables with the same name MUST have the same type in a single data set.



I show a method to identify which variables in are in which datasets here, but you can modify it to also show type.



Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation