From the course: SAS Programming for R Users, Part 1

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Match-merging data sets

Match-merging data sets

- [Narrator] Now the merge statement is much more powerful than the way I've previously detailed. Instead of just doing a straight C-bind, we can actually merge according to a common variable in each data set. And in the next few examples I'll show you how to do a one-to-one, one-to-many-, and non-match merge. To actually do the following match merging, you have to first go ahead and sort your data by that common variable. And to do so you'll just use Proc Sort. That's a really easy procedure which you can go ahead and look up on the online doc page in your own time. Once you go ahead and use the sort procedure, then you can use your data step and use the merge statement. And you'll list all the data tables you want to merge according to some common variable. And to tell SAS what that common variable is, you'll list it in the by statement. So imagine I have a data set called employees and a data set called phone, which obviously holds the names of my employees and the phone numbers…

Contents