Winning and loosing streaks in 2010:
data bb0;
infile "&sasforum\datasets\GL2010.txt" dsd;
input date :$8. gameNumber :$1. day :$3.
teamV :$3. leagueV :$2. gameV
teamH :$3. leagueH :$2. gameH
scoreV scoreH;
run;
data bb;
set bb0;
length game $9 team $7;
game = cats(date, gameNumber);
team = catx("-", teamV, leagueV);
location = "V";
teamScore = scoreV; opponentScore = scoreH;
win = teamScore > opponentScore;
output;
team = catx("-", teamH, leagueH);
location = "H";
teamScore = scoreH; opponentScore = scoreV;
win = teamScore > opponentScore;
output;
keep game team location win teamScore opponentScore;
run;
proc sort data=bb; by team game; run;
data streaks;
streak = 0;
do until (last.win);
set bb; by team win notsorted;
streak + 1;
end;
keep team win streak;
run;
proc format;
value win
0 = "Loosing"
1 = "Winning"
;
run;
proc sql;
create table teamStreaks as
select team, win format=win., max(streak) as longestStreak
from streaks
group by team, win;
quit;
... View more