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 3.sas
1 /* "Chapter 7 SCD 3.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 0 then set template.Players_SCD3;
8  if _n_ = 1 then
9  do; /* define the hash table */
10  dcl hash scd(dataset:
11  ifc(exist("bizarro.Players_SCD3")
12  ,"bizarro.Players_SCD3"
13  ,"template.Players_SCD3"
14  )
15  ,ordered:"A",multidata:"Y");
16  scd.defineKey("Player_ID");
17  scd.defineData("Player_ID","Debut_Team_SK","Team_SK"
18  ,"First_Name","Last_Name"
19  ,"Position_Code","Bats","Throws");
20  scd.defineDone();
21  end; /* define the hash table */
22  set bizarro.atbats(rename=(Batter_ID = Player_ID))
23  end=lr;
24  _Team_SK = Team_SK;
25  if scd.find() then scd.add(Key:Player_ID
26  ,Data:Player_ID
27  ,Data:Team_SK
28  ,Data:Team_SK
29  ,Data:First_Name
30  ,Data:Last_Name
31  ,Data:Position_Code
32  ,Data:Bats
33  ,Data:Throws
34  );
35  else scd.replace(Key:Player_ID
36  ,Data:Player_ID
37  ,Data:Debut_Team_SK
38  ,Data:_Team_SK
39  ,Data:First_Name
40  ,Data:Last_Name
41  ,Data:Position_Code
42  ,Data:Bats
43  ,Data:Throws
44  );
45  if lr;
46  scd.output(dataset:"bizarro.Players_SCD3");
47 run;