From the course: SAS® 9.4 Cert Prep: Part 12 Combining Tables

Unlock this course with a free trial

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

Processing a one-to-many merge

Processing a one-to-many merge

- [Instructor] Let's look at how SAS processes this one to many merge during execution. SAS reads the first rows in each table, finds a by-value match, and writes values from both tables to the PDV. At the end of the data step, SAS writes the contents of the PDV to the output table and processing returns to the top of the data step. Similar to the set statement, values read from the tables in the merge statement are automatically retained. For the next row in each table, the by-values don't match. So SAS checks to see if either by-value matches the current contents of the PDV. In this case, Alfred in the test2_sort table matches the current value for name in the PDV. So SAS reads the row from test2_sort and overwrites the previous values for name, subject, and test score. The values for grade and teacher from the first table are retained. Once again, the end of the data step triggers an implicit output and implicit…

Contents