Here is an SPSS program that will calculate weekly stats for your team and your opponent's team. I've done some annotations within the file to describe what's being done at various points. title "READ PRIOR WEEK'S AL HITTING STATS (THROUGH SUNDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96bat.512" / id 1- 4 player 6-17 (A) frstname 22-26 (a) team 33-35 (a) games1 37-39 ab1 41-43 runs1 45-47 hits1 49-51 b21 52-54 b31 55-57 hr1 58-60 rbi1 62-64 sb1 66-68 cs1 69-71 bb1 73-75 k1 77-79 err1 80-82. ** input format set for TQS stat files; change names/fields for other sources ** create new variable 'league' (AL, NL) on basis of team names string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. ** select/save previous weeks stats for AL players in system file 'split1al' select if (league eq 'AL'). save outfile = split1al. *************************************************************************** title "READ PRIOR WEEK'S NL HITTING STATS (THROUGH MONDAY) AND COMBINE". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96bat.513" / id 1- 4 player 6-17 (A) frstname 22-26 (a) team 33-35 (a) games1 37-39 ab1 41-43 runs1 45-47 hits1 49-51 b21 52-54 b31 55-57 hr1 58-60 rbi1 62-64 sb1 66-68 cs1 69-71 bb1 73-75 k1 77-79 err1 80-82. ** input format same but data file is cumulative through Monday (not Sunday) ** create 'league' variable same as before string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. ** select NL players from this file and combine with AL data for same week select if (league eq 'NL'). add files file = split1al / file = *. ** create variables needed for calculation of baseline OBFBL stats ** sort file by player id number and save baseline hitting data compute rp1 = (runs1+rbi1)-hr1. compute rpa1 = (rp1/ab1). compute ba1 = (hits1/ab1). sort cases by id(a). save outfile = basebat. ************************************************************************ TITLE "READ CURRENT WEEK'S AL HITTING STATS (THROUGH SUNDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96bat.519" / id 1- 4 player 6-17 (A) frstname 22-26 (a) team 33-35 (a) games2 37-39 ab2 41-43 runs2 45-47 hits2 49-51 b22 52-54 b32 55-57 hr2 58-60 rbi2 62-64 sb2 66-68 cs2 69-71 bb2 73-75 k2 77-79 err2 80-82. ** create 'league' variable and save AL data for current week string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. select if (league eq 'AL'). save outfile = split2al. ************************************************************************* TITLE "READ CURRENT NL HITTING STATS (THROUGH MON.); COMBINE WITH AL.". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96bat.520" / id 1- 4 player 6-17 (A) frstname 22-26 (a) team 33-35 (a) games2 37-39 ab2 41-43 runs2 45-47 hits2 49-51 b22 52-54 b32 55-57 hr2 58-60 rbi2 62-64 sb2 66-68 cs2 69-71 bb2 73-75 k2 77-79 err2 80-82. string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. select if (league eq 'NL'). ADD FILES FILE = split2al / file = * . set length = none. set width = 80. ** create variables needed for calculation of this week's OBFBL hitting stats ** sort file by player id number and then combine with baseline hitting data compute rp2 = (runs2+rbi2)-hr2. compute rpa2 = (rp2/ab2). compute ba2 = (hits2/ab2). SORT CASES BY id(a). MATCH FILES FILE = basebat / file = * / BY id. ** select own team's hitters and opponent's hitters ** (could be done on ID basis rather than player/team basis; ** selection on player/name basis is sensitive to cap vs lower case) Select if ((PLAYER EQ "Alomar" AND Team eq "Cle") OR (PLAYER EQ "Galarraga" and team eq "Col") or (PLAYER EQ "Larkin" and team eq "Cin") OR (PLAYER EQ "Livingstone" and team eq "SD ") or (PLAYER EQ "Bonds" and team eq "SF ") or (player eq "Kent" and team eq "NYN") or (PLAYER EQ "Bichette" and team eq "Col") or (PLAYER EQ "Cianfrocco" and team eq "SD ") or (PLAYER EQ "McLemore" and team eq "Tex") or (PLAYER EQ "Tinsley" and team eq "Phi") or (PLAYER EQ "Hoiles" and team eq "Bal") or (player eq "Carr" and team eq "Mil") or (player eq "Owens" and team eq "Cin") or (PLAYER EQ "Ausmus" and team eq "SD ") or (PLAYER EQ "Snow" and team eq "Cal") or (PLAYER EQ "Alicea" and team eq "StL") or (PLAYER EQ "Thompson" and team eq "SF ") or (PLAYER EQ "Bonilla" and team eq "Bal") or (player eq "Weiss" and team eq "Col") or (PLAYER EQ "Kelly" and team eq "Min") or (PLAYER EQ "Murray" and team eq "Cle") or (PLAYER EQ "Garciaparra" and team eq "Bos") or (PLAYER EQ "Kelly" and team eq "NYA") or (PLAYER EQ "Johnson" and team eq "SD ") or (player eq "Fabregas" and team eq "Cal") or (player eq "Phillips" and team eq "ChA") or (player eq "Hosey" and team eq "Bos")). ** compute this week's hitting stats for own/opponent players and ** set parameters for printing of these variables COMPUTE AB = AB2-AB1. COMPUTE HITS = HITS2-HITS1. COMPUTE HR = HR2-HR1. COMPUTE SB = SB2-SB1. COMPUTE RBI = RBI2-RBI1. COMPUTE ba = HITS/AB. COMPUTE RUNS = RUNS2-RUNS1. COMPUTE RP = (RUNS2-RUNS1)+(RBI2-RBI1)-(HR2-HR1). COMPUTE RPA = RP/ab. print formats ab hits runs rbi hr sb rp (f3) ba RPA (f5.3). ** choose starting players & assign to OBFBL category (own, opponent, backup) IF ((PLAYER EQ "Alomar" AND Team eq "Cle") OR (PLAYER EQ "Galarraga" and team eq "Col") or (PLAYER EQ "Larkin" and team eq "Cin") OR (PLAYER EQ "Bonds" and team eq "SF ") or (player eq "Kent" and team eq "NYN") or (PLAYER EQ "Bichette" and team eq "Col") or (PLAYER EQ "McLemore" and team eq "Tex") or (PLAYER EQ "Hoiles" and team eq "Bal") or (player eq "Carr" and team eq "Mil")) bfbl = 1. IF ((PLAYER EQ "Ausmus" and team eq "SD ") or (PLAYER EQ "Thompson" and team eq "SF ") or (PLAYER EQ "Bonilla" and team eq "Bal") or (PLAYER EQ "Weiss" and team eq "Col") or (PLAYER EQ "Murray" and TEAM EQ "Cle") or (player eq "Phillips" and team eq "ChA") or (PLAYER EQ "Kelly" and team eq "Min") or (PLAYER EQ "Hosey" and team eq "Bos") or (PLAYER EQ "Snow" and team eq "Cal")) bfbl = 2. IF MISSING (bfbl) bfbl = 3. VALUE LABELS bfbl 1 "HEM" 2 "OPP" 3 "BCK". ** sort cases by bfbl category and generate weekly stats report ** (SPSS requires sorting prior to generation of report) sort cases by bfbl (A) . REPORT FORMAT=AUTOMATIC LIST /VARIABLES = PLAYER AB RUNS HITS HR RBI SB BA RPA RP /BREAK = bfbl (SKIP(3)) /SUMMARY = VALIDN (PLAYER) /SUMMARY = SUM (AB HITS RUNS RBI HR RP SB) "SUM" /SUMMARY = DIVIDE ( SUM(HITS) SUM(AB) ) "ba" (ba (3)) /summary = divide ( sum(rp) sum(ab) ) "RPA" (RPA (3)) /TITLE = LEFT "LAST WEEK'S STATS FOR HITTERS FROM BOTH TEAMS: )DATE". *************************************************************************** title "READ PRIOR WEEK'S STATS FOR AL PITCHERS (THROUGH SUNDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96pit.512" / id 1-4 PLAYER 6-17 (A) frstname 22-26(a) team 33-35 (a) GAMES1 37-39 GS1 40-42 CG1 43-45 shut1 46-48 FINS1 49-51 win1 52-54 loss1 55-57 sav1 58-60 bs1 61-63 IP11 64-67 IP21 68-69(1) hits1 70-73 bb1 74-77 er1 78-81 k1 82-85 hr1 86-88. string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. select if (league eq 'AL'). save outfile = split3al. ************************************************************************** title "READ PRIOR WEEK'S STATS FOR NL PITCHERS (THROUGH MONDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96pit.513" / id 1-4 PLAYER 6-17 (A) frstname 22-26(a) team 33-35 (a) GAMES1 37-39 GS1 40-42 CG1 43-45 shut1 46-48 FINS1 49-51 win1 52-54 loss1 55-57 sav1 58-60 bs1 61-63 IP11 64-67 IP21 68-69(1) hits1 70-73 bb1 74-77 er1 78-81 k1 82-85 hr1 86-88. string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. ** combine baseline stats for AL and NL pitchers; compute pertinent ** OBFBL stat variables; sort/save baseline pitching data in system file select if (league eq 'NL'). ADD FILES FILE = split3al / file = * . recode ip21 (.0 = 0) (.1 = .3333) (.2 = .6666). compute ip1 = ip11+ip21. compute hbb1 = hits1+bb1. compute whip1 = hbb1/ip1. compute era1 = (er1/ip1)*9. sort cases by id(a). save OUTFILE = basepit. ********************************************************************* title "READ CURRENT WEEK'S STATS FOR AL PITCHERS (THROUGH SUNDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96pit.519" / id 1-4 PLAYER 6-17 (A) frstname 22-26(a) team 33-35 (a) GAMES2 37-39 GS2 40-42 CG2 43-45 shut2 46-48 FINS2 49-51 win2 52-54 loss2 55-57 sav2 58-60 bs2 61-63 IP12 64-67 IP22 68-69(1) hits2 70-73 bb2 74-77 er2 78-81 k2 82-85 hr2 86-88. string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. select if (league eq 'AL'). save outfile = split4al. ************************************************************************** title "READ CURRENT WEEK'S STATS FOR NL PITCHERS (THROUGH MONDAY)". DATA LIST FILE = "c:\data\baseball\mlb_1996\mlb96pit.520" / id 1-4 PLAYER 6-17 (A) frstname 22-26(a) team 33-35 (a) GAMES2 37-39 GS2 40-42 CG2 43-45 shut2 46-48 FINS2 49-51 win2 52-54 loss2 55-57 sav2 58-60 bs2 61-63 IP12 64-67 IP22 68-69(1) hits2 70-73 bb2 74-77 er2 78-81 k2 82-85 hr2 86-88. string league (a2). if((team eq 'SF ') or (team eq 'LA ') or (team eq 'SD ') or (team eq 'Fla') or (team eq 'NYN') or (team eq 'ChN') or (team eq 'Phi') or (team eq 'Mon') or (team eq 'Cin') or (team = 'Hou') or (team eq 'Col') or (team eq 'Atl') or (team eq 'StL') or (team eq 'Pit')) league = 'NL'. if((team eq 'Cal') or (team eq 'Sea') or (team eq 'Det') or (team eq 'Tex') or (team eq 'Bal') or (team eq 'NYA') or (team eq 'ChA') or (team eq 'Min') or (team eq 'Bos') or (team = 'Mil') or (team eq 'Oak') or (team eq 'Cle') or (team eq 'KC ') or (team eq 'Tor')) league = 'AL'. ** select NL players; combine with AL data from current week; compute new ** variables needed for OBFBL pitching stats; sort data file for current ** week and merge with baseline data file select if (league eq 'NL'). ADD FILES FILE = split4al / file = * . RECODE IP22 (.0=0) (.1=.3333) (.2=.6666). COMPUTE IP2 = IP12+IP22. compute hbb2 = hits2+bb2. COMPUTE whip2 = hbb2/ip2. COMPUTE era2 = (er2/ip2)*9. SORT CASES BY id(a). MATCH FILES FILE=basepit / file = * / BY id. ** select own/opponent's players and designate starters/reserves SELECT IF ( (player eq "Candiotti" and team eq "LA ") or (player eq "Hanson" and team eq "Tor") or (player eq "Drabek" and team eq "Hou") or (PLAYER EQ "Harnisch" and team eq "NYN") OR (PLAYER EQ "Jones" and team eq "NYN") OR (PLAYER EQ "Key" and team eq "NYA") or (PLAYER EQ "Olson" and team eq "Det") or (PLAYER EQ "Hoffman" and team eq "SD ") or (PLAYER EQ "Russell" and team eq "Tex") or (PLAYER EQ "Wagner" and team eq "Hou") or (PLAYER EQ "Cone" and team eq "NYA") or (PLAYER EQ "Bullinger" and team eq "ChN") or (PLAYER EQ "Fernandez" and team eq "SF ") or (PLAYER EQ "Urbina" and team eq "Mon") or (PLAYER EQ "Sodowsky" and team eq "Det") or (PLAYER EQ "Wetteland" and team eq "NYA") or (player eq "Saberhagen" and team eq "Col") or (player eq "Osuna" and team eq "LA ") or (PLAYER EQ "McMichael" and team eq "Atl")). IF ((player eq "Candiotti" and team eq "LA ") or (player eq "Hanson" and team eq "Tor") or (player eq "Jones" and team eq "NYN") or (PLAYER EQ "Harnisch" and team eq "NYN") OR (PLAYER EQ "Drabek" and team eq "Hou") or (PLAYER EQ "Hoffman" and team eq "SD ") or (PLAYER EQ "Russell" and team eq "Tex") or (player eq "Olson" and team eq "Det")) bfbl=1. IF ((PLAYER EQ "Bullinger" and team eq "ChN") or (PLAYER EQ "Fernandez" and team eq "SF ") or (PLAYER EQ "Urbina" and team eq "Mon") or (PLAYER EQ "Cone" and team eq "NYA") or (PLAYER EQ "McMichael" and team eq "Atl") or (player eq "Osuna" and team eq "LA ")) bfbl=2. IF MISSING (bfbl) bfbl = 3. VALUE LABELS bfbl 1 'HEM' 2 'OPP' 3 'BCK'. ** calculate pitching stats for this week; set print parameters; ** generate report for this week's pitching stats compute GS=gs2-gs1. COMPUTE IP=IP2-IP1 . COMPUTE HIT=HITS2-HITS1. COMPUTE BB=BB2-BB1. COMPUTE ER=ER2-ER1. COMPUTE WIN=WIN2-WIN1. COMPUTE SAV=sav2-sav1. COMPUTE CR=(Hit+BB)/IP. COMPUTE ERA=(ER/IP)*9. compute HBB=(Hit+BB). print formats ip era cr (f6.2) gs win sav hit er bb hbb (f2). SORT CASES BY bfbl (A). REPORT FORMAT=AUTOMATIC LIST /VARIABLES = PLAYER GS WIN SAV IP HIT ER BB ERA CR hbb /BREAK = bfbl (SKIP(3)) /SUMMARY = VALIDN (PLAYER) /SUMMARY = SUM ( gs IP HBB hit bb ER WIN SAV) 'SUM' /SUMMARY = DIVIDE ( SUM(ER) SUM(IP) 9) (ERA (2)) 'ERA' /SUMMARY = DIVIDE ( SUM(HBB) SUM(IP) ) (CR (2)) 'CR' /TITLE = LEFT "LAST WEEK'S STATS FOR PITCHERS FROM BOTH TEAMS )DATE".