1 Answers
Performing a Three-Way Merge in SAS
In SAS, a three-way merge can be performed to handle matching and non-matching observations from multiple datasets. Here's how you can achieve this:
- Use the MERGE statement with the IN= option to identify the source of each observation.
- Create three separate data sets: one for matching observations, one for non-matching observations from the left-most dataset, and one for non-matching observations from the right-most dataset.
- Specify the BY statement to indicate the variables used for matching observations.
- Use the IF-THEN statements to direct the observations to the appropriate output dataset based on the IN= option.
By following these steps, you can efficiently perform a three-way merge in SAS, ensuring that matching observations are written to one dataset, while non-matching observations from the left-most and right-most datasets are directed to separate datasets.

Please login or Register to submit your answer