Creating a Cartesian Product in SAS

Posted by bkloss | SAS | Friday 13 February 2009 6:49 am

Here’s the first of several question/answer posts.

Feel free to write me with your SAS question and I’ll provide the answer in a post.

Question

Suppose I have two SAS datasets, set A contains 5 variables having 3000 unique records and set B contains just 1 variable having 500 unique records (just a bunch of ID numbers). Suppose I would like to create a new dataset where each of the records from set A would be duplicated so that the first record would be repeated 500 times where each of those would be paired with a unique ID from set B. The goal is to have the new dataset with 6 variables (the five from A and the one from B) containing a total of 1,500,000 records produced in this way.

Any help or suggestions you can provide is greatly appreciated.

(more…)