[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Data management: looking up content in observations

From   "Florian Kuhn" <>
To   <>
Subject   st: Data management: looking up content in observations
Date   Sun, 1 Mar 2009 22:10:18 -0600


I am trying to find out if in a league winning the previous game has an effect on the current game. Specifically, I have 8 teams, named A to H. I would like to construct the variable "winlast", being 1 if the current home team won the last game and 0 otherwise.
The data is organized as follows:

Day hometeam guestteam winner (winlast)
1  A  H  A (.)
1  C  F  .  (.)
1  E  B  B  (.)
1  G  D  D  (.)
2  F  E  .  (0)
2  B  G  G  (1)
2  H  C  C  (0)
2  D  A  D (1)
3  G  E  E  (1)

That is, for each observation I would like to check whether the home team is listed as "winner" for the previous day. I get the right digit by (for example)

count if day == 1 & winner == F

but I have no idea of how to incorporate this into an egen command (that is, I had a lot of ideas none of which worked).
Does someone know how to get this right?
Thanks, Florian
*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index