Statalist


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

st: Data management: looking up content in observations


From   "Florian Kuhn" <florian@mail.utexas.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Data management: looking up content in observations
Date   Sun, 1 Mar 2009 22:10:18 -0600

Hi,

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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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