As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 7 SCD 1.sas
1 /* "Chapter 7 SCD 1.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 _null_;
7  if _n_ = 1 then
8  do; /* define the hash table */
9  dcl hash scd(dataset:
10  ifc(exist("bizarro.Players_SCD1")
11  ,"bizarro.Players_SCD1"
12  ,"template.Players_SCD1"
13  )
14  ,ordered:"A");
15  scd.defineKey("Player_ID");
16  scd.defineData("Team_SK","Player_ID","First_Name"
17  ,"Last_Name","Position_Code");
18  scd.defineDone();
19  end; /* define the hash table */
20  set bizarro.atbats(rename=(Batter_ID=Player_ID))
21  end=lr;
22  rc = scd.replace();
23  if lr;
24  scd.output(dataset:"Bizarro.Players_SCD1");
25  stop;
26  set template.players_scd1;
27 run;
28 
29 data tableLookUp;
30  /* sample lookup code */
31  if 0 then set bizarro.players_SCD1;
32  dcl hash scd(dataset:"bizarro.players_SCD1");
33  scd.defineKey("Player_ID");
34  scd.defineData("Team_SK","Player_ID","First_Name"
35  ,"Last_Name","Position_Code");
36  scd.defineDone();
37 
38  /* first a key with no data items */
39  call missing(Team_SK,First_Name,Last_Name
40  ,Position_Code);
41  Player_Id = 00001;
42  RC = scd.find();
43  output;
44  /* now a key with a row of data items */
45  call missing(Team_SK,First_Name,Last_Name
46  ,Position_Code);
47  Player_Id = 10103;
48  RC = scd.find();
49  output;
50  stop;
51 run;