As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Player_SCD_All.sas
1 /* "Player_SCD_All.sas" from the SAS Press book
2  Data Management Solutions Using SAS Hash Table Operations:
3  A Business Intelligence Case Study
4 */
5 
6 proc sql;
7  create table TEMPLATE.PLAYERS_SCD0
8  (
9  Player_ID num format=Z5. label = "Player ID",
10  Team_SK num label = "Team Surrogate Key",
11  First_Name char(12) informat=$12. label = "First Name",
12  Last_Name char(12) informat=$12. label = "Last Name",
13  Position_Code char(3) informat=$3. label "Batter Position",
14  Bats char(1) informat=$1. label = "Bats L, R or Switch",
15  Throws char(1) informat=$1. label = "Throws L or R"
16  );
17 quit;
18 
19 data TEMPLATE.PLAYERS_SCD1;
20  set TEMPLATE.PLAYERS_SCD0;
21 run;
22 
23 proc sql;
24  create table TEMPLATE.PLAYERS_SCD2
25  (
26  Player_ID num format=Z5. label = "Player ID",
27  Team_SK num label = "Team Surrogate Key",
28  First_Name char(12) informat=$12. label = "First Name",
29  Last_Name char(12) informat=$12. label = "Last Name",
30  Position_Code char(3) informat=$3. label "Batter Position",
31  Bats char(1) informat=$1. label = "Bats L, R or Switch",
32  Throws char(1) informat=$1. label = "Throws L or R",
33  Start_Date num format=YYMMDD10. label = "First Game Date",
34  End_Date num format=YYMMDD10. label = "Last Game Date"
35  );
36  create table TEMPLATE.PLAYERS LIKE TEMPLATE.PLAYERS_SCD2(drop=Position_Code);
37 quit;
38 
39 proc sql;
40  create table TEMPLATE.PLAYERS_SCD3
41  (
42  Player_ID num format=Z5. label = "Player ID",
43  Debut_Team_SK num label = "Debut Team Surrogate Key",
44  Team_SK num label = "Current Team Surrogate Key",
45  First_Name char(12) informat=$12. label = "First Name",
46  Last_Name char(12) informat=$12. label = "Last Name",
47  Bats char(1) informat=$1. label = "Bats L, R or Switch",
48  Throws char(1) informat=$1. label = "Throws L or R",
49  Position_Code char(3) informat=$3. label "Batter Position"
50  );
51 quit;
52 
53 proc sql;
54  create table TEMPLATE.PLAYERS_SCD3_FACTS
55  (
56  Player_ID num format=Z5. label = "Player ID",
57  Team_SK num label = "Current Team Surrogate Key",
58  First_Name char(12) informat=$12. label = "First Name",
59  Last_Name char(12) informat=$12. label = "Last Name",
60  First num label = "Games at First",
61  Second num label = "Games at Second",
62  Short num label = "Games at ShortStop",
63  Third num label = "Games at Third",
64  Left num label = "Games in Left",
65  Center num label = "Games in Center",
66  Right num label = "Games in Right",
67  Catcher num label = "Games at Catcher",
68  Pitcher num label = "Games at Pitcher",
69  Pinch_Hitter num label = "Games as a Pinch Hitter"
70  );
71  create table template.PLAYERS_POSITIONS_PLAYED LIKE TEMPLATE.PLAYERS_SCD3_FACTS;
72 quit;
73 
74 proc sql;
75  create table TEMPLATE.PLAYERS_SCD6
76  (
77  Player_ID num format=Z5. label = "Player ID",
78  Active num label = "Currently Active?",
79  SubKey num label = "Secondary Key",
80  Team_SK num label = "Team Surrogate Key",
81  First_Name char(12) informat=$12. label = "First Name",
82  Last_Name char(12) informat=$12. label = "Last Name",
83  Position_Code char(3) informat=$3. label "Batter Position",
84  Bats char(1) informat=$1. label = "Bats L, R or Switch",
85  Throws char(1) informat=$1. label = "Throws L or R",
86  Start_Date num format=YYMMDD10. label = "First Game Date",
87  End_Date num format=YYMMDD10. label = "Last Game Date"
88  );
89 quit;