As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 5 GenerateTeams.sas
1 /* "Chapter 5 GenerateTeams.sas" from the SAS Press book
2  Data Management Solutions Using SAS Hash Table Operations:
3  A Business Intelligence Case Study
4 */
5 
6 data bizarro.teams;
7  /* Select team names from 100 most popular team names.
8  Source: http://mascotdb.com/lists.php?id=5
9  */
10  keep League_SK Team_SK Team_Name;
11  keep League; /* fix for rename issue found post-publication */
12  label League_SK = "League Surrogate Key"
13  Team_SK = "Team Surrogate Key"
14  Team_Name = "Team Name"
15  ;
16  retain League_SK . Team_SK 100;
17  if _n_ = 1 then
18  do; /* create hash table */
19  declare hash teams();
20  rc = teams.defineKey("Team_Name");
21  rc = teams.defineData("Team_SK","Team_Name");
22  rc = teams.defineDone();
23  end; /* create hash table */
24  infile datalines eof=lr;
25  input Team_Name $16.;
26  Team_SK + ceil(uniform(&seed1)*4);
27  rc = teams.add();
28  return;
29  lr:
30  declare hiter teamIter("teams");
31  do i = 1 to 2*&nTeamsPerLeague;
32  rc = teamIter.next();
33  League_SK = int((i-1)/&nTeamsPerLeague) + 1;
34  League = League_SK; /* fix for rename issue found post-publication */
35  output;
36  end;
37 datalines;
38 Eagles
39 Tigers
40 Bulldogs
41 Panthers
42 Wildcats
43 Warriors
44 Lions
45 Indians
46 Cougars
47 Knights
48 Mustangs
49 Falcons
50 Trojans
51 Cardinals
52 Vikings
53 Pirates
54 Raiders
55 Rams
56 Spartans
57 Bears
58 Hornets
59 Patriots
60 Hawks
61 Crusaders
62 Rebels
63 Bobcats
64 Saints
65 Braves
66 Blue Devils
67 Titans
68 Wolverines
69 Jaguars
70 Wolves
71 Dragons
72 Pioneers
73 Chargers
74 Rockets
75 Huskies
76 Red Devils
77 Yellowjackets
78 Chiefs
79 Stars
80 Comets
81 Colts
82 Lancers
83 Rangers
84 Broncos
85 Giants
86 Senators
87 Bearcats
88 Thunder
89 Royals
90 Storm
91 Cowboys
92 Cubs
93 Cavaliers
94 Golden Eagles
95 Generals
96 Owls
97 Buccaneers
98 Hurricanes
99 Bruins
100 Grizzlies
101 Gators
102 Bombers
103 Red Raiders
104 Flyers
105 Lakers
106 Miners
107 Redskins
108 Coyotes
109 Longhorns
110 Greyhounds
111 Beavers
112 Yellow Jackets
113 Outlaws
114 Reds
115 Highlanders
116 Sharks
117 Oilers
118 Jets
119 Dodgers
120 Mountaineers
121 Red Sox
122 Thunderbirds
123 Blazers
124 Clippers
125 Aces
126 Buffaloes
127 Lightning
128 Bluejays
129 Gladiators
130 Mavericks
131 Monarchs
132 Tornadoes
133 Blues
134 Cobras
135 Bulls
136 Express
137 Stallions
138 ;
139 data bizarro.leagues;
140  label League_SK = "League Surrogate Key"
141  League = "League"
142  ;
143  League_SK = 1;
144  League = 'Eastern';
145  output;
146  League_SK = 2;
147  League = 'Western';
148  output;
149 run;