<>
well, why do you want an -egen- function? Note there is an -egen, count-
command already, which, in combination with -by-, might just do what you
want. -help subscripting- may also be useful.
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Florian Kuhn
Gesendet: Montag, 2. März 2009 05:10
An: [email protected]
Betreff: st: Data management: looking up content in observations
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/
*
* 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/