I am trying to count the number of times an NFL has won a game in their last four games. I already have a dummy variable representing the outcome of the game. I think the idea would be to generate the id for each game after sorting them in order by team and game time and then count the dummy variable outcomes from the last four observations. I'm not entirely sure how to go about the syntax/loop as I'm not super familiar doing these things in stata. Let me know if any more information is needed. I would probably have to drop the first four games in each season as well.