10 %let root=%sysfunc(pathname(sasuser));
11 %*let root = /folders/myfolders/BizarroBall;
14 libname bizarro
"&root/Data";
15 libname DW
"&root/DW";
16 libname
template "&root/Data/Template";
19 %let SCD_End_Date =
'31DEC9999'd;
26 %let nTeamsPerLeague = 16;
27 %let seasonStartDate = 20MAR2017;
28 %let nWeeksSeason = %eval((&nTeamsPerLeague-1)*2);
29 %let nPlayersPerTeam = 25;
30 %let nBattersPerGame = 9;
54 ,hashTable = hashTable
55 ,metaData =
template.Schema_Metadata
58 if 0 then
set template.&hashTable;
59 dcl hash _&hashTable(dataset:
"&lib..&hashtable" 65 where upcase(hashTable) =
"%upcase(&hashTable)";
66 if is_a_key then _&hashTable..DefineKey(Column);
67 _&hashTable..DefineData(Column);
69 _&hashTable..DefineDone();
77 %macro generateLineUps
83 %let from = %sysfunc(inputn(&from,date9.));
84 %let to = %eval(&from + &nweeks*7 - 1);
86 %
do date = &from %to &to;
93 set template.LineUps bizarro.Positions_Snowflake;
99 declare hash positions(dataset:
"bizarro.Positions");
100 positions.defineKey(
"Position_Grp_SK");
101 positions.defineData(
"Position_Grp_SK",
"Position_Code",
"Count",
"Starters");
102 positions.defineDone();
103 declare hiter positionIter(
"positions");
105 declare hash positions_snowflake(dataset:
"bizarro.Positions_Snowflake",ordered:
"A",multidata:
"Y");
106 positions_snowflake.defineKey(
"Position_Grp_FK");
107 positions_snowflake.defineData(
"Position_Grp_FK",
"Position_Code");
108 positions_snowflake.defineDone();
110 declare hash LineUp(multidata:
"Y");
111 rc = LineUp.defineKey(
"Game_SK",
"Team_SK");
112 rc = LineUp.defineData(
"Game_SK",
"Team_SK",
"Date",
"Batting_Order",
"Player_ID",
"First_Name",
"Last_Name",
"Position_Code",
"Bats",
"Throws");
113 rc = LineUp.defineDone();
115 declare hash players(dataset:
"bizarro.Player_Candidates(where=(Team_SK))",ordered:
"A",multidata:
"Y");
116 rc = players.defineKey(
"Team_SK",
"Position_Code");
117 rc = players.defineData(
"Team_SK",
"Player_ID",
"First_Name",
"Last_Name",
"Bats",
"Throws");
118 rc = players.defineDone();
121 set bizarro.trades end = lr;
122 where trade_date le &date;
123 do while(players.do_over(Key:_team_sk,Key:_Position_Code) = 0);
124 if player_id = traded_id then
128 Position_Code = _Position_Code;
135 declare hash games(dataset:
"bizarro.Games(where=(date=&date))",multidata:
"Y");
136 rc = games.defineKey(
"Date");
137 rc = games.defineData(
"Game_SK",
"Away_SK",
"Home_SK");
138 rc = games.defineDone();
140 games_rc = games.find(Key:&date);
141 do while (games_rc = 0);
142 do team_sk = away_sk, home_sk;
143 rc = positionIter.first();
144 P_Grp = Position_Code;
145 grp_rc = positions_snowflake.find(Key:Position_Grp_SK);
147 prc = players.find(Key:Team_SK,Key:P_grp);
149 Batting_Order = uniform(&seed5*&date);
150 if divide(Starters,Count) gt Batting_Order then
152 if position_code =
"SP" then Batting_Order = 9;
154 if grp_rc = 0 then grp_rc = positions_snowflake.find_next(Key:Position_Grp_SK);
157 else if position_code ne
"SP" then
159 _position_code = position_code;
160 if position_code =
'RP' then Batting_Order = 1e6;
164 Position_Code =
'PH';
167 position_code = _position_code;
170 prc = players.find_next(Key:Team_SK,Key:P_grp);
172 *
if Position_Code =
'UT' then
174 * Batting_Order = 9 + uniform(&seed5*&date);
175 *Position_Code =
'PH';
178 rc=positionIter.next();
179 P_Grp = Position_Code;
180 grp_rc = positions_snowflake.find(Key:Position_Grp_SK);
183 games_rc = games.find_next();
185 LineUp.output(dataset:
"Lineups");
189 proc sort data = lineups out = lineups;
190 by game_sk team_sk batting_order;
193 %
if %sysfunc(exist(bizarro.LineUps)) %then
196 delete from bizarro.Lineups
197 where Game_SK in (select distinct Game_SK from Lineups);
202 data bizarro.LineUps;
207 data bizarro.LineUps(index=(LineUp=(Game_SK Team_SK)));
212 if first.team_sk then Order=0;
214 if batting_order ne int(batting_order) and
new then batting_order = min(Order,9);
217 %mend generateLineUps;
223 %macro generatePitchAndPAData
229 %let from = %sysfunc(inputn(&from,date9.));
230 %let to = %eval(&from + &nweeks*7 - 1);
232 %
do date = &from %to &to;
236 if 0 then
set template.AtBats
template.Pitches
template.Runs;
238 retain Inning 1 Pitcher_ID . Date &date;
239 length data_to_load $16;
240 array runners(*) onFirst onSecond onThird;
245 declare hash pitch_dist(ordered:"A");
246 rc = pitch_dist.DefineKey("Index");
247 rc = pitch_dist.DefineData("Index","Result","AB_Done","Is_An_Ab","Is_An_Out","Is_A_Hit","Is_An_OnBase"
248 ,"Bases","Runners_Advance_Factor","Pitch_Distribution_SK");
249 rc = pitch_dist.DefineDone();
252 set bizarro.pitch_distribution end=lr;
253 do Index = From to To;
254 rc =pitch_dist.add();
259 declare hash hit_distance(dataset:"bizarro.hit_distance"
260 || "(rename=(Pitch_Distribution_FK=Pitch_Distribution_SK))");
261 rc = hit_distance.DefineKey("Pitch_Distribution_SK");
262 rc = hit_distance.DefineData("MinDistance","MaxDistance");
263 rc = hit_distance.DefineDone();
266 declare hash batters(ordered:"A",multidata:"Y");
267 rc = batters.DefineKey("Top_Bot","Batting_Order");
268 rc = batters.DefineData("Team_SK","Top_Bot","Batter_ID","First_Name","Last_Name","Position_Code","Bats","Throws");
269 rc = batters.DefineDone();
271 declare hash pitchers(ordered:"D",multidata:"Y");
272 rc = pitchers.DefineKey("Top_Bot");
273 rc = pitchers.DefineData("Team_SK","Top_Bot","Pitcher_ID","First_Name","Last_Name","Position_Code","Pitcher_Bats","Pitcher_Throws");
274 rc = pitchers.DefineDone();
276 if exist("bizarro.Runs")
277 then data_to_load = "bizarro.Runs";
278 else data_to_load = "template.Runs";
279 declare hash facts_runs(dataset:data_to_load
282 facts_runs.DefineKey("Date","Game_SK");
283 facts_runs.DefineData("Game_SK","Date","Batter_ID"
285 ,"AB_Number","Runner_ID");
286 facts_runs.DefineDone();
288 if exist("bizarro.Pitches") then data_to_load = "bizarro.Pitches";
289 else data_to_load = "template.Pitches";
290 declare hash facts_pitches(dataset:data_to_load,ordered:"A",multidata:"Y");
291 facts_pitches.DefineKey("Date","Game_SK");
292 facts_pitches.DefineData("Game_SK","Date","Team_SK","Pitcher_ID","Pitcher_First_Name","Pitcher_Last_Name"
293 ,"Pitcher_Bats","Pitcher_Throws","Pitcher_Type","Inning","Top_Bot","Result","AB_Number","Outs"
294 ,"Balls","Strikes","Pitch_Number","Is_A_Ball","Is_A_Strike","onBase");
295 facts_pitches.DefineDone();
297 if exist("bizarro.AtBats") then data_to_load = "bizarro.AtBats";
298 else data_to_load = "template.AtBats";
299 declare hash facts_atbats(dataset:data_to_load,ordered:"A",multidata:"Y");
300 facts_atbats.DefineKey("Date","Game_SK");
301 facts_atbats.DefineData("Game_SK","Date","Time","League","Away_SK","Home_SK","Team_SK"
302 ,"Batter_ID","First_Name","Last_Name","Position_Code","Inning"
303 ,"Top_Bot","Bats","Throws","AB_Number","Result","Direction","Distance"
304 ,"Outs","Balls","Strikes","onFirst","onSecond","onThird","onBase"
305 ,"Left_On_Base","Runs","Is_An_AB","Is_An_Out","Is_A_Hit","Is_An_OnBase"
306 ,"Bases","Number_of_Pitches");
307 facts_atbats.DefineDone();
313 facts_runs.output(dataset:"bizarro.Runs");
314 facts_pitches.output(dataset:"bizarro.Pitches");
315 facts_atbats.output(dataset:"bizarro.AtBats");
318 set bizarro.games end=lr;
322 if game_sk ne lag(game_sk) then
324 if facts_runs.check() = 0 then facts_runs.remove();
325 if facts_pitches.check() = 0 then facts_pitches.remove();
326 if facts_atbats.check() = 0 then facts_atbats.remove();
330 rc = batters.clear();
331 rc = pitchers.clear();
333 do team_sk = away_sk, home_sk;
334 do until(_iorc_ ne 0);
335 set bizarro.LineUps key = LineUp;
338 rc = batters.add(Key:Top_Bot,Key:Batting_Order,Data:Team_SK,Data:Top_Bot,Data:Player_ID,Data:First_Name,Data:Last_Name,Data:Position_Code,Data:Bats,Data:Throws);
339 if Position_Code in ("SP" "RP") then rc = pitchers.add(Key:Top_Bot,Data:Team_SK,Data:Top_Bot,Data:Player_ID,Data:First_Name,Data:Last_Name,Data:Position_Code,Data:Bats,Data:Throws);
349 array _halfInning(2) ab_t ab_b;
350 call missing(ab_t,ab_b);
354 do Top_Bot = "T", "B";
356 rc = pitchers.find(key:Top_Bot);
358 rc = pitchers.has_next(result:not_last);
359 if inning ge 6 and not_last then
361 rc=pitchers.removeDup();
362 pitchers.find(key:Top_Bot);
365 Pitcher_First_Name = First_Name;
366 Pitcher_Last_Name = Last_Name;
367 Pitcher_Type = Position_Code;
369 call missing(onFirst,onSecond,onThird);
375 _halfInning(ab_index) + 1;
376 AB_Number = _halfInning(ab_index);
377 rc = batters.find(key:Top_Bot,Key:mod(AB_Number-1,&nBattersPerGame)+1);
379 rc = batters.has_next(result:not_last);
380 if mod(AB_Number,&nBattersPerGame)= 0 and inning ge 6 and not_last then
382 rc=batters.removeDup();
383 batters.find(key:Top_Bot,Key:mod(AB_Number-1,&nBattersPerGame)+1);
388 Index = ceil(100*uniform(&seed6*&date));
389 rc = pitch_dist.find();
392 call missing(Is_A_Ball,Is_A_Strike);
393 if Result = "Ball" then Is_A_Ball = 1;
394 else if find(Result,"strike","i") then Is_A_Strike = 1;
395 else if Result = "Foul" and Strikes lt 2 then Is_A_Strike = 1;
397 Strikes + Is_A_Strike;
399 AB_Done = (Balls = 4 or Strikes = 3);
403 call missing(Is_An_AB,Is_An_Out,Is_A_Hit);
405 Runners_Advance_Factor = 1;
408 else if Strikes = 3 then
410 Result = "Strikeout";
414 call missing(Is_A_Hit,Bases);
417 else facts_pitches.add();
420 call missing(MinDistance,MaxDistance,Direction,Distance);
421 if hit_distance.find()=0 then
423 Direction = ceil(18*uniform(&seed7*&date));
424 Distance = MinDistance + ceil((MaxDistance-MinDistance)*uniform(&seed8*&date));
426 onBase = 3 - nmiss(of runners(*));
431 Advance = Bases + (Runners_Advance_Factor > uniform(&seed9*Date));
432 do i = dim(runners) to 1 by -1;
435 if i+Advance ge 4 then
438 Runner_ID = runners(i);
441 else runners(i+Advance) = runners(i);
445 if bases lt 4 then runners(bases) = batter_id;
449 Runner_ID = Batter_ID;
453 else Left_On_Base = onBase;
454 Number_of_Pitches = Pitch_Number;
464 %mend generatePitchAndPAData;
471 create table TEMPLATE.ATBATS
473 Game_SK
char(16) format=$HEX32. label = "Game Surrogate Key",
474 Date num format=YYMMDD10. label = "Game Date",
475 Time num format=TIMEAMPM8. label = "Game Time",
476 League num label = "League",
477 Home_SK num label = "Home Team Surrogate Key",
478 Away_SK num label = "Away Team Surrogate Key",
479 Team_SK num label = "Team Surrogate Key",
480 Batter_ID num label = "Batter ID",
481 First_Name
char(12) label = "Batter First Name",
482 Last_Name
char(12) label = "Batter Last Name",
483 Position_Code
char(3) label "Batter Position",
484 Inning num label = "Inning",
485 Top_Bot
char(1) label = "Which Half Inning",
486 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
487 Throws
char(1) informat=$1. label = "Throws L or R",
488 AB_Number num label = "At Bat Number in Game",
489 Result
char(16) label = "Result of the At Bat",
490 Direction num label='Hit Direction',
491 Distance num label = 'Hit Distance',
492 Outs num label = "Number of Outs",
493 Balls num label = "Number of Balls",
494 Strikes num label = "Number of Strikes",
495 onFirst num label = "ID of Runner on First",
496 onSecond num label = "ID of Runner on Second",
497 onThird num label = "ID of Runner on Third",
498 onBase num label = "Number of Men on Base at Beginning of AB",
499 Left_On_Base num label = "Number of Men Left on Base at End of AB",
500 Runs num label = "Runs Scored",
501 Is_An_AB num label = "Counts as an AB",
502 Is_An_Out num label = "Is an Out",
503 Is_A_Hit num label = "Is a Hit",
504 Is_An_OnBase num label = "Counts as an On Base",
505 Bases num label = "Number of Bases for the Hit",
506 Number_of_Pitches num label = "Number of Pitches This AB"
514 data template.Chapter8parmfile ;
516 hashTable length= $32 label="Member Name"
517 Column length= $32 label="Column Name"
520 infile cards dsd delimiter=',';
527 BYDAYOFWEEK,DayOfWeek,1
536 BYDAYOFWEEK,_Reached_Base,0
546 BYMONTH,_Reached_Base,0
548 BYPLAYER,First_Name,1
558 BYPLAYER,_Reached_Base,0
559 BYPLAYERMONTH,Last_Name,1
560 BYPLAYERMONTH,First_Name,1
561 BYPLAYERMONTH,Batter_ID,1
562 BYPLAYERMONTH,Month,1
564 BYPLAYERMONTH,AtBats,0
570 BYPLAYERMONTH,_Bases,0
571 BYPLAYERMONTH,_Reached_Base,0
582 BYTEAM,_Reached_Base,0
590 data template.Chapter9lookuptables ;
592 hashTable length= $32 label="Member Name"
593 Column length= $32 label="Column Name"
595 datasetTag length= $200
597 infile cards dsd delimiter=',';
605 GAMES,Game_SK,1,DW.GAMES
606 GAMES,Date,0,DW.GAMES
607 GAMES,Time,0,DW.GAMES
608 GAMES,Year,0,DW.GAMES
609 GAMES,Month,0,DW.GAMES
610 GAMES,DayOfWeek,0,DW.GAMES
611 GAMES,League,0,DW.GAMES
612 GAMES,Home_SK,0,DW.GAMES
613 GAMES,Away_SK,0,DW.GAMES
614 PLAYERS,Player_ID,1,DW.PLAYERS
615 PLAYERS,Team_SK,0,DW.PLAYERS
616 PLAYERS,First_Name,0,DW.PLAYERS
617 PLAYERS,Last_Name,0,DW.PLAYERS
618 PLAYERS,Bats,0,DW.PLAYERS
619 PLAYERS,Throws,0,DW.PLAYERS
620 PLAYERS,Start_Date,0,DW.PLAYERS
621 PLAYERS,End_Date,0,DW.PLAYERS
622 TEAMS,Team_SK,1,DW.TEAMS
623 TEAMS,Team_Name,0,DW.TEAMS
624 TEAMS,League_SK,0,DW.TEAMS
632 data template.Chapter9splits ;
634 hashTable length= $32 label="Member Name"
635 Column length= $32 label="Column Name"
638 infile cards dsd delimiter=',';
645 BYDAYOFWEEK,DayOfWeek,1
654 BYDAYOFWEEK,_Reached_Base,0
664 BYMONTH,_Reached_Base,0
666 BYPLAYER,First_Name,1
676 BYPLAYER,_Reached_Base,0
677 BYPLAYERMONTH,Last_Name,1
678 BYPLAYERMONTH,First_Name,1
679 BYPLAYERMONTH,Player_ID,1
680 BYPLAYERMONTH,Month,1
682 BYPLAYERMONTH,AtBats,0
688 BYPLAYERMONTH,_Bases,0
689 BYPLAYERMONTH,_Reached_Base,0
700 BYTEAM,_Reached_Base,0
709 create table TEMPLATE.GAMES
711 Game_SK
char(16) format=$HEX32. label = "Game Surrogate Key"
712 ,Date num format=YYMMDD10. label = "Game Date"
713 ,Time num format=TIMEAMPM8. label = "Game Time"
714 ,Year num label = "Year"
715 ,Month num label = "Month"
716 ,DayOfWeek num Label = "Day of the Week"
717 ,League_SK num label = "League"
718 ,Home_SK num label = "Home Team Surrogate Key"
719 ,Away_SK num label = "Away Team Surrogate Key"
729 create table TEMPLATE.LINEUPS
731 Game_SK
char(16) format=$HEX32. label = "Game Surrogate Key",
732 Date num format=YYMMDD10. label = "Game Date",
733 Team_SK num label = "Team Surrogate Key",
734 Batting_Order num label = "Lineup Position",
735 Player_ID num format=Z5. label = "Player ID",
736 First_Name
char(12) informat=$12. label = "First Name",
737 Last_Name
char(12) informat=$12. label = "Last Name",
738 Position_Code
char(3) informat=$3. label "Position",
739 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
740 Throws
char(1) informat=$1. label = "Throws L or R"
742 create index LineUp on template.LINEUPS(Game_SK,Team_SK);
750 create table TEMPLATE.PITCHES
752 Game_SK
char(16) format=$HEX32. label = "Game Surrogate Key",
753 Date num format=YYMMDD10. label = "Game Date",
754 Team_SK num label = "Team Surrogate Key",
755 Pitcher_ID num label = "Pitcher_ID",
756 Pitcher_First_Name
char(12) label = "Pitcher_First_Name",
757 Pitcher_Last_Name
char(12) label = "Pitcher_Last_Name",
758 Pitcher_Bats
char(1) informat=$1. label = "Bats L, R or Switch",
759 Pitcher_Throws
char(1) informat=$1. label = "Throws L or R",
760 Pitcher_Type
char(3) label "Starter or Reliever",
761 Inning num label = "Inning",
762 Top_Bot
char(1) label = "Which Half Inning",
763 Result
char(16) label = "Result of the At Bat",
764 AB_Number num label = "At Bat Number in Game",
765 Outs num label = "Number of Outs",
766 Balls num label = "Number of Balls",
767 Strikes num label = "Number of Strikes",
768 Pitch_Number num label = "Pitch Number in the AB",
769 Is_A_Ball num label = "Pitch is a Ball",
770 Is_A_Strike num label ="Pitch is Strike",
771 onBase num label ="Number of Men on Base"
780 create table TEMPLATE.PLAYER_CANDIDATES
782 Player_ID num format=Z5. label = "Player ID",
783 Team_SK num label = "Team Surrogate Key",
784 First_Name
char(12) informat=$12. label = "First Name",
785 Last_Name
char(12) informat=$12. label = "Last Name",
786 Position_Code
char(3) informat=$3. label = "Batter Position",
787 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
788 Throws
char(1) informat=$1. label = "Throws L or R"
797 create table TEMPLATE.PLAYERS_SCD0
799 Player_ID num format=Z5. label = "Player ID",
800 Team_SK num label = "Team Surrogate Key",
801 First_Name
char(12) informat=$12. label = "First Name",
802 Last_Name
char(12) informat=$12. label = "Last Name",
803 Position_Code
char(3) informat=$3. label "Batter Position",
804 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
805 Throws
char(1) informat=$1. label = "Throws L or R"
809 data TEMPLATE.PLAYERS_SCD1;
810 set TEMPLATE.PLAYERS_SCD0;
814 create table TEMPLATE.PLAYERS_SCD2
816 Player_ID num format=Z5. label = "Player ID",
817 Team_SK num label = "Team Surrogate Key",
818 First_Name
char(12) informat=$12. label = "First Name",
819 Last_Name
char(12) informat=$12. label = "Last Name",
820 Position_Code
char(3) informat=$3. label "Batter Position",
821 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
822 Throws
char(1) informat=$1. label = "Throws L or R",
823 Start_Date num format=YYMMDD10. label = "First Game Date",
824 End_Date num format=YYMMDD10. label = "Last Game Date"
826 create table TEMPLATE.PLAYERS LIKE TEMPLATE.PLAYERS_SCD2(drop=Position_Code);
830 create table TEMPLATE.PLAYERS_SCD3
832 Player_ID num format=Z5. label = "Player ID",
833 Debut_Team_SK num label = "Debut Team Surrogate Key",
834 Team_SK num label = "Current Team Surrogate Key",
835 First_Name
char(12) informat=$12. label = "First Name",
836 Last_Name
char(12) informat=$12. label = "Last Name",
837 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
838 Throws
char(1) informat=$1. label = "Throws L or R",
839 Position_Code
char(3) informat=$3. label "Batter Position"
844 create table TEMPLATE.PLAYERS_SCD3_FACTS
846 Player_ID num format=Z5. label = "Player ID",
847 Team_SK num label = "Current Team Surrogate Key",
848 First_Name
char(12) informat=$12. label = "First Name",
849 Last_Name
char(12) informat=$12. label = "Last Name",
850 First num label = "Games at First",
851 Second num label = "Games at Second",
852 Short num label = "Games at ShortStop",
853 Third num label = "Games at Third",
854 Left num label = "Games in Left",
855 Center num label = "Games in Center",
856 Right num label = "Games in Right",
857 Catcher num label = "Games at Catcher",
858 Pitcher num label = "Games at Pitcher",
859 Pinch_Hitter num label = "Games as a Pinch Hitter"
861 create table template.PLAYERS_POSITIONS_PLAYED LIKE TEMPLATE.PLAYERS_SCD3_FACTS;
865 create table TEMPLATE.PLAYERS_SCD6
867 Player_ID num format=Z5. label = "Player ID",
868 Active num label = "Currently Active?",
869 SubKey num label = "Secondary Key",
870 Team_SK num label = "Team Surrogate Key",
871 First_Name
char(12) informat=$12. label = "First Name",
872 Last_Name
char(12) informat=$12. label = "Last Name",
873 Position_Code
char(3) informat=$3. label "Batter Position",
874 Bats
char(1) informat=$1. label = "Bats L, R or Switch",
875 Throws
char(1) informat=$1. label = "Throws L or R",
876 Start_Date num format=YYMMDD10. label = "First Game Date",
877 End_Date num format=YYMMDD10. label = "Last Game Date"
886 create table TEMPLATE.RUNS
888 Game_SK
char(16) format=$HEX32. label = "Game Surrogate Key",
889 Date num format=YYMMDD10. label = "Game Date",
890 Batter_ID num label = "Batter ID",
891 Inning num label = "Inning",
892 Top_Bot
char(1) label = "Which Half Inning",
893 AB_Number num label = "At Bat Number in Game",
894 Runner_ID num label = "ID of Runner Who Scored"
902 data template.SCHEMA_METADATA ;
904 hashTable length= $32 label="Member Name"
905 Column length= $32 label="Column Name"
908 infile cards dsd delimiter=',';
917 ATBATS,Position_Code,.
931 ATBATS,Left_On_Base,.
936 ATBATS,Is_An_OnBase,.
938 ATBATS,Number_of_Pitches,.
939 CHAPTER10LOOKUPTABLES,hashTable,1
940 CHAPTER10LOOKUPTABLES,Column,.
941 CHAPTER10LOOKUPTABLES,Is_A_Key,.
942 CHAPTER10LOOKUPTABLES,datasetTag,.
943 CHAPTER10SPLITS,hashTable,1
944 CHAPTER10SPLITS,Column,.
945 CHAPTER10SPLITS,is_A_Key,.
946 CHAPTER9PARMFILE,hashTable,1
947 CHAPTER9PARMFILE,Column,.
948 CHAPTER9PARMFILE,is_A_Key,.
960 LINEUPS,Batting_Order,.
962 LINEUPS,Position_Code,.
967 PITCHES,Pitcher_First_Name,.
968 PITCHES,Pitcher_Last_Name,.
969 PITCHES,Pitcher_Type,.
977 PITCHES,Pitch_Number,.
979 PITCHES,Is_A_Strike,.
989 PLAYERS_POSITIONS_PLAYED,Player_ID,1
990 PLAYERS_POSITIONS_PLAYED,First,.
991 PLAYERS_POSITIONS_PLAYED,Second,.
992 PLAYERS_POSITIONS_PLAYED,Short,.
993 PLAYERS_POSITIONS_PLAYED,Third,.
994 PLAYERS_POSITIONS_PLAYED,Left,.
995 PLAYERS_POSITIONS_PLAYED,Center,.
996 PLAYERS_POSITIONS_PLAYED,Right,.
997 PLAYERS_POSITIONS_PLAYED,Catcher,.
998 PLAYERS_POSITIONS_PLAYED,Pitcher,.
999 PLAYERS_POSITIONS_PLAYED,Pinch_Hitter,.
1016 keep League_SK Team_SK Team_Name;
1018 label League_SK = "League Surrogate Key"
1019 Team_SK = "Team Surrogate Key"
1020 Team_Name = "Team Name"
1022 retain League_SK . Team_SK 100;
1025 declare hash teams();
1026 rc = teams.defineKey("Team_Name");
1027 rc = teams.defineData("Team_SK","Team_Name");
1028 rc = teams.defineDone();
1030 infile datalines eof=lr;
1031 input Team_Name $16.;
1032 Team_SK + ceil(uniform(&seed1)*4);
1036 declare hiter teamIter("teams");
1037 do i = 1 to 2*&nTeamsPerLeague;
1038 rc = teamIter.next();
1039 League_SK =
int((i-1)/&nTeamsPerLeague) + 1;
1145 data bizarro.leagues;
1146 label League_SK = "League Surrogate Key"
1162 infile datalines eof=readall;
1166 declare hash positions(ordered:"a");
1167 positions.defineKey("Position_Grp_SK");
1168 positions.defineData("Position_Grp_SK","Position_Code","Position","Count","Starters");
1169 positions.defineDone();
1171 informat Position_Code $3. Position $17. Count Starters 8.;
1172 label Position_Grp_SK = "Position Group Surrogate Key"
1173 Position_Code = "Position Code"
1174 Position = "Position Description"
1175 Count = "Number of Players"
1176 Starters = "Number of Starters"
1178 input Position_Code Position & Count Starters;
1179 Position_Grp_SK + 1;
1184 positions.output(dataset:"Bizarro.Positions");
1187 SP Starting Pitcher 4 1
1188 RP Relief Pitcher 6 0
1190 CIF Corner Infielder 3 2
1191 MIF Middle Infielder 3 2
1192 COF Corner Outfielder 3 2
1193 CF Center Fielder 2 1
1197 infile datalines eof=readall;
1201 declare hash positions(ordered:"a");
1202 positions.defineKey("Position_SK");
1203 positions.defineData("Position_SK","Position_Grp_FK","Position_Code","Position");
1204 positions.defineDone();
1206 informat Position_Grp_FK 8. Position_Code $3. Position $17.;
1207 label Position_SK = "Position Surrogate Key"
1208 Position_Grp_FK = "Position Group Surrogate Key"
1209 Position_Code = "Position Code"
1210 Position = "Position Description"
1213 input Position_Grp_FK Position_Code Position &;
1219 positions.output(dataset:"Bizarro.Positions_Snowflake");
1237 informat First_Name $12.;
1239 First_Name = propcase(First_Name);
1346 informat Last_Name $12.;
1348 Last_Name = propcase(Last_Name);
1453 if 0 then set template.player_candidates;
1454 retain Player_ID 10000 Team_SK 0;
1455 declare hash positionsDist();
1456 rc = positionsDist.defineKey("Index");
1457 rc = positionsDist.defineData("Index","Position_Code","Count");
1458 rc = positionsDist.defineDone();
1462 set bizarro.positions end=lr;
1465 rc = positionsDist.add();
1468 rc = positionsDist.output(dataset:"positions");
1470 declare hash fname(dataset: "first_names");
1471 rc = fname.defineKey("First_Name");
1472 rc = fname.defineData("First_Name");
1473 rc = fname.defineDone();
1474 declare hiter first_iter("fname");
1476 declare hash lname(dataset: "last_names");
1477 rc = lname.defineKey("Last_Name");
1478 rc = lname.defineData("Last_Name");
1479 rc = lname.defineDone();
1480 declare hiter last_iter("lname");
1482 declare hash players();
1483 rc = players.defineKey("Arbtrary","First_Name","Last_Name");
1484 rc = players.defineData("Player_ID","Team_SK","First_Name","Last_Name"
1485 ,"Position_Code","Bats","Throws");
1486 rc = players.defineDone();
1489 do frc = first_iter.first() by 0 while(frc = 0);
1490 do lrc = last_iter.first() by 0 while(lrc = 0);
1492 positionsDist.find(Key:ceil(uniform(&seed2)*&nPlayersPerTeam));
1493 Player_ID + ceil(uniform(&seed3)*9);
1494 random = uniform(&seed10);
1495 if random le .1 then Bats = "S";
1496 else if random le .35 then Bats = "L";
1498 if uniform(&seed11) le .3 then Throws = "L";
1501 lrc = last_iter.next();
1503 frc = first_iter.next();
1505 players.output(dataset:"bizarro.player_candidates");
1513 set bizarro.positions;
1520 if 0 then set template.player_candidates;
1521 retain Player_ID 10000 Start_Date "01MAR2017"d End_Date &SCD_End_Date;
1522 format Player_ID z5. Start_Date End_Date mmddyy10.;
1523 informat Start_Date End_Date yymmdd10.;
1526 declare hash available(dataset:"bizarro.player_candidates",multidata:"yes");
1527 rc = available.defineKey("Position_Code");
1528 rc = available.defineData("Player_ID","Team_SK","First_Name","Last_Name"
1529 ,"Position_Code","Bats","Throws");
1530 rc = available.defineDone();
1533 declare hash positions(dataset:"positions",multidata:"yes");
1534 rc = positions.defineKey("DummyKey");
1535 rc = positions.defineData("Position_Code","Count");
1536 rc = positions.defineDone();
1539 declare hash teams(dataset:"Bizarro.teams");
1540 rc = teams.defineKey("Team_SK");
1541 rc = teams.defineDone();
1542 declare hiter teams_iter("teams");
1545 pos_rc = positions.find();
1546 avail_rc = available.find();
1548 teams_rc = teams_iter.first();
1553 available.replaceDup();
1554 avail_rc = available.find_next();
1556 teams_rc = teams_iter.next();
1558 pos_rc = positions.find_next();
1559 avail_rc = available.find();
1561 rc = available.output(dataset:"bizarro.player_candidates");
1564 data bizarro.trades;
1565 format trade_date yymmdd10.;
1566 input trade_date yymmdd10. traded_id _position_code $3. _team_sk traded_to;
1568 2017/06/23 10090 SP 269 115
1569 2017/06/23 10753 SP 115 269
1570 2017/07/26 10103 COF 171 228
1571 2017/07/26 10760 COF 228 171
1572 2017/08/30 10145 CF 193 130
1573 2017/08/30 10732 CF 130 193
1582 retain Team_SK Team1_SK Team2_SK .;
1583 format Date yymmdd10.;
1585 declare hash team1(dataset:"bizarro.teams(rename=(Team_SK=Team1_SK))",multidata:"y");
1586 rc = team1.defineKey("League_SK");
1587 rc = team1.defineData("League_SK","Team1_SK");
1588 rc = team1.defineDone();
1590 declare hash team2(dataset:"bizarro.teams(rename=(Team_SK=Team2_SK))",multidata:"y");
1591 rc = team2.defineKey("League_SK");
1592 rc = team2.defineData("League_SK","Team2_SK");
1593 rc = team2.defineDone();
1595 declare hash matchUps(multidata:"y");
1596 rc = matchUps.defineKey("League_SK");
1597 rc = matchUps.defineData("League_SK","Team1_SK","Team2_SK");
1598 rc = matchUps.defineDone();
1600 declare hash used();
1601 rc = used.defineKey("League_SK","Team_SK");
1602 rc = used.defineData("League_SK","Team_SK");
1603 rc = used.defineDone();
1605 declare hash schedule();
1606 rc = schedule.defineKey("League_SK","Team1_SK","Team2_SK");
1607 rc = schedule.defineData("League_SK","Team1_SK","Team2_SK","Date","Home");
1608 rc = schedule.defineDone();
1610 do League_SK = 1 to 2;
1611 Team1_rc = team1.find();
1612 do while(Team1_rc=0);
1613 Team2_rc = team2.find();
1614 do while(Team2_rc=0);
1615 if Team2_SK ne Team1_SK then
1617 addrc = matchUps.add();
1619 Team2_rc = team2.find_next();
1621 Team1_rc = team1.find_next();
1625 do League_SK = 1 to 2;
1626 Date = "&seasonStartDate"d - 3;
1627 do Combo = 1 to &nWeeksSeason;
1628 if mod(combo,2) = 1 then Date + 3;
1631 matchUps_rc = matchUps.find();
1632 do while(matchUps_rc = 0 and games lt &nTeamsPerLeague/2);
1633 if used.check(key:League_SK,key:Team1_SK) ne 0
1634 and used.check(key:League_SK,key:Team2_SK) ne 0
1637 Home = ceil(uniform(&seed4)*2);
1638 if schedule.add() = 0 then
1641 rc = used.add(Key:League_SK,Key:Team1_SK,Data:League_SK,Data:Team1_SK);
1642 rc = used.add(Key:League_SK,Key:Team2_SK,Data:League_SK,Data:Team1_SK);
1645 matchUps_rc = matchUps.find_next();
1650 schedule.output(dataset:"Games");
1654 proc sort data = games out = games;
1659 if 0 then set template.games;
1660 drop Team1_SK Team2_SK Home D;
1661 format Time Timeampm8.;
1666 array _homeaway team1_sk team2_sk;
1667 Home_SK = _homeaway(Home);
1668 Away_SK = _homeaway(3-Home);
1671 Month = Month(Date);
1672 DayOfWeek = weekday(Date);
1673 if DayOfWeek = 5 then Time = "16:00"t;
1674 else if DayOfWeek = 1 then Time = "13:00"t;
1675 else time = "19:00"t;
1676 Game_SK = md5(catx(":",League_SK,Away_SK,Home_SK,Date,Time));
1680 D + 7*&nWeeksSeason/2;
1681 Home_SK = _homeaway(3-Home);
1682 Away_SK = _homeaway(Home);
1685 Month = Month(Date);
1686 DayOfWeek = weekday(Date);
1687 Game_SK = md5(catx(":",League_SK,Away_SK,Home_SK,Date,Time));
1696 data bizarro.pitch_distribution;
1697 Pitch_Distribution_SK = _n_;
1698 input Result $16. AB_Done Is_An_AB Is_An_Out Is_A_Hit Is_An_OnBase Bases Runners_Advance_Factor From To;
1699 label Pitch_Distribution_SK = "Pitch Distribution Surrogate Key"
1700 Result = "Result of the Pitch"
1701 AB_Done = "Final Pitch of the AB"
1702 Is_An_AB = "Counts as an AB"
1703 Is_An_Out = "Is an Out"
1704 Is_A_Hit = "Is a Hit"
1705 Is_An_OnBase = "Counts as an On Base"
1706 Bases = "Number of Bases for the Hit"
1707 Runners_Advance_Factor = "Proabability of an Extra Base"
1708 From = "Lower Range of Distribution"
1709 to = "Upper Range of Distribution"
1712 Ball 0 . . . . . . 1 33
1713 Called Strike 0 . . . . . . 34 48
1714 Double 1 1 0 1 1 2 .7 49 51
1715 Error 1 1 0 0 0 1 .4 52 52
1716 Foul 0 . . . . . . 53 68
1717 Hit By Pitch 1 0 0 0 1 1 0 69 69
1718 Home Run 1 1 0 1 1 4 0 70 71
1719 Out 1 1 1 0 0 0 0 72 83
1720 Single 1 1 0 1 1 1 .5 84 88
1721 Swinging Strike 0 . . . . . . 89 99
1722 Triple 1 1 0 1 1 3 0 100 100
1725 data bizarro.hit_distance;
1726 Hit_Distance_SK = _n_;
1727 input Pitch_Distribution_FK MinDistance MaxDistance;
1728 label Hit_Distance_SK = "Hit Distance Surrogate Key"
1729 Pitch_Distribution_FK = "Pitch Distribution Foreign Key"
1730 MinDistance = "Hit Distance Minimum"
1731 MaxDistance = "Hit Distance Maximum"
1740 run;%generateLineUps(from=&seasonStartDate,nWeeks=&nWeeksSeason)
1741 %generatePitchAndPAData(from=&seasonStartDate,nWeeks=&nWeeksSeason)
1747 proc datasets lib = dw nolist;
1749 copy in=bizarro out=dw;
1754 copy in=template out=dw;
1755 select Players_Positions_Played Players;
1758 copy in=bizarro out=dw;
1767 alter table dw.teams
1778 dcl hash scd(dataset:
1779 ifc(exist("bizarro.Players_SCD0")
1780 ,"bizarro.Players_SCD0"
1781 ,"template.Players_SCD0"
1784 scd.defineKey("Player_ID");
1785 scd.defineData("Team_SK","Player_ID","First_Name"
1786 ,"Last_Name","Position_Code");
1789 set bizarro.AtBats(rename=(Batter_ID=Player_ID))
1793 scd.output(dataset:"Bizarro.Players_SCD0");
1795 set template.Players_SCD0;
1800 if 0 then set bizarro.Players_SCD0;
1801 dcl hash scd(dataset:"bizarro.Players_SCD0");
1802 scd.defineKey("Player_ID");
1803 scd.defineData("Team_SK","Player_ID","First_Name"
1804 ,"Last_Name","Position_Code");
1808 call missing(Team_SK,First_Name,Last_Name
1815 call missing(Team_SK,First_Name,Last_Name
1829 dcl hash scd(dataset:
1830 ifc(exist("bizarro.Players_SCD1")
1831 ,"bizarro.Players_SCD1"
1832 ,"template.Players_SCD1"
1835 scd.defineKey("Player_ID");
1836 scd.defineData("Team_SK","Player_ID","First_Name"
1837 ,"Last_Name","Position_Code");
1840 set bizarro.atbats(rename=(Batter_ID=Player_ID))
1844 scd.output(dataset:"Bizarro.Players_SCD1");
1846 set template.players_scd1;
1851 if 0 then set bizarro.players_SCD1;
1852 dcl hash scd(dataset:"bizarro.players_SCD1");
1853 scd.defineKey("Player_ID");
1854 scd.defineData("Team_SK","Player_ID","First_Name"
1855 ,"Last_Name","Position_Code");
1859 call missing(Team_SK,First_Name,Last_Name
1865 call missing(Team_SK,First_Name,Last_Name
1877 if 0 then set template.Players_SCD2;
1880 dcl hash scd(dataset:
1881 ifc(exist("bizarro.Players_SCD2")
1882 ,"bizarro.Players_SCD2"
1883 ,"template.Players_SCD2"
1885 ,ordered:"A",multidata:"Y");
1886 scd.defineKey("Player_ID");
1887 scd.defineData("Player_ID","Team_SK"
1888 ,"First_Name","Last_Name"
1889 ,"Position_Code","Bats","Throws"
1890 ,"Start_Date","End_Date");
1895 (rename = (Batter_ID = Player_ID
1897 First_Name = _First_Name
1898 Last_Name = _Last_Name
1899 Position_Code = _Position_Code
1905 if scd.check() ne 0 then
1907 scd.add(key: Player_ID
1912 ,data: _Position_Code
1916 ,data: &SCD_End_Date
1924 if (Start_Date le Date le End_Date) then leave;
1925 RC = scd.find_next();
1928 if catx(":", Team_SK, First_Name, Last_Name
1929 , Position_Code, Bats, Throws) ne
1930 catx(":",_Team_SK,_First_Name,_Last_Name
1931 ,_Position_Code,_Bats,_Throws) then
1933 if RC = 0 then scd.replaceDup(data: Player_ID
1937 ,data: Position_Code
1943 scd.add(key: Player_ID
1948 ,data: _Position_Code
1952 ,data: &SCD_End_Date
1957 scd.output(dataset:"bizarro.Players_SCD2");
1963 if 0 then set bizarro.Players_SCD2;
1966 dcl hash scd(dataset:"bizarro.Players_SCD2"
1968 scd.defineKey("Player_ID");
1969 scd.defineData("Team_SK","Player_ID","First_Name"
1970 ,"Last_Name","Position_Code","Bats"
1971 ,"Throws","Start_Date","End_Date");
1975 attrib Date format = yymmdd10. informat = yymmdd10.;
1976 input Player_ID Date;
1979 if (Start_Date le Date le End_Date) then leave;
1980 RC = scd.find_next();
1982 if RC ne 0 then call missing(Team_SK,First_Name
1983 ,Last_Name,Position_Code
1985 ,Start_Date,End_Date);
1998 if 0 then set template.Players_SCD3_Facts;
2001 dcl hash scd(dataset:
2002 ifc(exist("bizarro.Players_SCD3_Facts")
2003 ,"bizarro.Players_SCD3_Facts"
2004 ,"template.Players_SCD3_Facts"
2007 scd.defineKey("Player_ID");
2008 scd.defineData("Player_ID","Team_SK"
2009 ,"First_Name","Last_Name"
2010 ,"First","Second","Short","Third"
2011 ,"Left","Center","Right","Catcher"
2012 ,"Pitcher","Pinch_Hitter");
2014 dcl hash uniqueGames();
2015 uniqueGames.defineKey("Game_SK"
2018 uniqueGames.defineDone();
2020 set bizarro.AtBats(rename = (Batter_ID = Player_ID))
2022 if scd.find() ne 0 then
2023 call missing(First,Second,Short,Third
2024 ,Left,Center,Right,Catcher
2025 ,Pitcher,Pinch_Hitter);
2026 select(Position_Code);
2027 when("1B") First + (uniqueGames.add() = 0);
2028 when("2B") Second + (uniqueGames.add() = 0);
2029 when("SS") Short + (uniqueGames.add() = 0);
2030 when("3B") Third + (uniqueGames.add() = 0);
2031 when("LF") Left + (uniqueGames.add() = 0);
2032 when("CF") Center + (uniqueGames.add() = 0);
2033 when("RF") Right + (uniqueGames.add() = 0);
2034 when("C" ) Catcher + (uniqueGames.add() = 0);
2035 when("SP") Pitcher + (uniqueGames.add() = 0);
2036 when("RP") Pitcher + (uniqueGames.add() = 0);
2037 when("PH") Pinch_Hitter + (uniqueGames.add() = 0);
2042 scd.output(dataset:"Bizarro.Players_SCD3_Facts");
2049 if 0 then set template.Players_SCD3;
2052 dcl hash scd(dataset:
2053 ifc(exist("bizarro.Players_SCD3")
2054 ,"bizarro.Players_SCD3"
2055 ,"template.Players_SCD3"
2057 ,ordered:"A",multidata:"Y");
2058 scd.defineKey("Player_ID");
2059 scd.defineData("Player_ID","Debut_Team_SK","Team_SK"
2060 ,"First_Name","Last_Name"
2061 ,"Position_Code","Bats","Throws");
2064 set bizarro.atbats(rename=(Batter_ID = Player_ID))
2067 if scd.find() then scd.add(Key:Player_ID
2077 else scd.replace(Key:Player_ID
2088 scd.output(dataset:"bizarro.Players_SCD3");
2095 if 0 then set template.Players_SCD6;
2098 dcl hash scd(dataset:
2099 ifc(exist("bizarro.Players_SCD6")
2100 ,"bizarro.Players_SCD6"
2101 ,"template.Players_SCD6"
2103 ,ordered:"A",multidata:"Y");
2104 scd.defineKey("Player_ID");
2105 scd.defineData("Player_ID","Active","SubKey"
2106 ,"Team_SK","First_Name","Last_Name"
2107 ,"Position_Code","Bats","Throws"
2108 ,"Start_Date","End_Date");
2112 (rename = (Batter_ID = Player_ID
2114 First_Name = _First_Name
2115 Last_Name = _Last_Name
2116 Position_Code = _Position_Code
2120 if scd.check(Key:Player_ID) ne 0 then
2122 scd.add(key: Player_ID
2129 ,data: _Position_Code
2133 ,data: &SCD_End_Date
2141 if (Start_Date le Date le End_Date) then leave;
2142 RC = scd.find_next();
2145 call missing(Team_SK,First_Name,Last_Name
2146 ,Position_Code,Bats,Throws);
2148 if catx(":", Team_SK, First_Name, Last_Name
2149 , Position_Code, Bats, Throws) ne
2150 catx(":",_Team_SK,_First_Name,_Last_Name
2151 ,_Position_Code,_Bats,_Throws) then
2155 scd.replaceDup(data: Player_ID
2161 ,data: Position_Code
2172 RC = scd.find_next();
2173 _SubKey = max(_SubKey,SubKey);
2175 scd.add(key: Player_ID
2182 ,data: _Position_Code
2186 ,data: &SCD_End_Date
2191 scd.output(dataset:"Bizarro.Players_SCD6"
2192 || "(index=(SCD6=(Player_ID Active SubKey)))");
2198 if 0 then set bizarro.Players_SCD6(drop=Subkey);
2201 dcl hash scd(dataset:"bizarro.Players_SCD6"
2202 ,multidata:"Y",ordered:"D");
2203 scd.defineKey("Player_ID","Active");
2204 scd.defineData("Team_SK","Player_ID","Active"
2205 ,"First_Name","Last_Name"
2206 ,"Position_Code","Bats","Throws"
2207 ,"Start_Date","End_Date");
2211 attrib Date format = yymmdd10. informat = yymmdd10.;
2212 input Player_ID Date;
2213 RC = scd.find(Key:Player_ID,Key:1);
2214 if RC = 0 and (Start_Date le Date le End_Date)
2218 RC = scd.find(Key:Player_ID,Key:0);
2220 if (Start_Date le Date le End_Date) then leave;
2221 RC = scd.find_next();
2225 call missing(Team_SK,Active,First_Name
2226 ,Last_Name,Position_Code,Bats
2227 ,Throws,Start_Date,End_Date);
2240 %createHash(hashTable=AtBats)
2241 %createHash(hashTable=Pitches)
2242 %createHash(hashTable=Runs)
2243 %createHash(hashTable=Games)
2244 %createHash(hashTable=Players_Positions_Played)
2245 %createHash(hashTable=Players)
2247 dcl hash uniqueGames();
2248 uniqueGames.defineKey("Game_SK"
2251 uniqueGames.defineDone();
2255 set bizarro.AtBats(rename = (Team_SK = _Team_SK
2256 First_Name = _First_Name
2257 Last_Name = _Last_Name
2261 if game_sk ne lag(game_sk) and _AtBats.check() = 0
2262 then _AtBats.remove();
2265 Player_ID = Batter_ID;
2266 link Positions_Played_SCD;
2269 _AtBats.output(dataset:"dw.AtBats");
2273 set bizarro.Pitches end=lr;
2274 if game_sk ne lag(game_sk) and _Pitches.check() = 0
2275 then _Pitches.remove();
2277 Player_ID = Pitcher_ID;
2279 _First_Name = Pitcher_First_Name;
2280 _Last_Name = Pitcher_Last_Name;
2281 _Bats = Pitcher_Bats;
2282 _Throws = Pitcher_Throws;
2284 Position_Code = Pitcher_Type;
2285 link Positions_Played_SCD;
2287 _Pitches.output(dataset:"dw.Pitches");
2291 set bizarro.Runs end=lr;
2292 if game_sk ne lag(game_sk) and _Runs.check() = 0
2293 then _Runs.remove();
2296 _Runs.output(dataset:"dw.Runs");
2299 _games.output(dataset:"dw.Games");
2300 _Players_Positions_Played.output
2301 (dataset:"dw.Players_Positions_Played");
2302 _Players.output(dataset:"dw.Players");
2307 Month = Month(Date);
2308 DayOfWeek = weekday(Date);
2312 Positions_Played_SCD:
2313 if _Players_Positions_Played.find() ne 0
2314 then call missing(First,Second,Short,Third,Left
2315 ,Center,Right,Catcher,Pitcher);
2316 select(Position_Code);
2317 when("1B") First + (uniqueGames.add() = 0);
2318 when("2B") Second + (uniqueGames.add() = 0);
2319 when("SS") Short + (uniqueGames.add() = 0);
2320 when("3B") Third + (uniqueGames.add() = 0);
2321 when("LF") Left + (uniqueGames.add() = 0);
2322 when("CF") Center + (uniqueGames.add() = 0);
2323 when("RF") Right + (uniqueGames.add() = 0);
2324 when("C" ) Catcher + (uniqueGames.add() = 0);
2325 when("SP") Pitcher + (uniqueGames.add() = 0);
2326 when("RP") Pitcher + (uniqueGames.add() = 0);
2327 when("PH") Pinch_Hitter + (uniqueGames.add() = 0);
2330 _Players_Positions_Played.replace();
2334 if _Players.check() ne 0 then
2336 _Players.add(key: Player_ID
2344 ,data: &SCD_End_Date
2350 RC = _Players.find();
2352 if (Start_Date le Date le End_Date) then leave;
2353 RC = _Players.find_next();
2356 if catx(":", Team_SK, First_Name, Last_Name
2358 catx(":",_Team_SK,_First_Name,_Last_Name
2359 ,_Bats,_Throws) then
2362 _Players.replaceDup(data: Player_ID
2371 _Players.add(key: Player_ID
2379 ,data: &SCD_End_Date