Hi: I am processing baseball dataset. I want to count the winning streak of a team winning. I created a variable called win, if team A wins it is 1, else it is 0. I want to create a variable called winstreak, if team A wins 1 time, it is 1, if team A wins 2 in a row, it is 2, Once team A loses it goes back to 0 again. So far I have tried: data phi2002;
set phi2002;
if (VisitingTeam = "PHI" and VisitorRunsScored > HomeRunsScore)
then PHIWIN = 1;
else if (HomeTeam = "PHI" and HomeRunsScore > VisitorRunsScored)
then PHIWIN = 1;
else PHIWIN = 0;
retain winstreak;
if PHIWIN = 1 then winstreak =+1;
else winstreak = 0;
run; The code doesnt work, since winstreak only shows the same value as PHIWIN. Please help!
... View more