Example 4.1 Performing a Simple Table Lookup


Find a match in a lookup table for the current value of the key column in the primary table. For observations in the primary table with no match in the lookup table, assign a default value to the lookup column.

Example Features

Featured StepPROC SQL
Featured Step Options and StatementsLeft join ON clause
Related Technique 1Hash object in the DATA step
Related Technique 2DATA step match-merge, MERGE statement with IN= option

Input Tables

Table SALARIES contains salaries for four employees identified by column EMPNUM. Table BRACKETS contains tax brackets for five employees. Column EMPNUM is common to both tables.


Obs  empnum     salary 1 1234 $125,000 2 3333 $85,000 3 4876 $54,000 4 5489 $29,000 ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.