Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: difficult merging issue


From   Rufus Peabody <[email protected]>
To   [email protected]
Subject   Re: st: RE: difficult merging issue
Date   Mon, 14 Jul 2008 01:28:36 -0700

Nick,

Thanks a lot. I meant reshape, not merge. I don't know why I wrote merge. Thanks again!

-Rufus

On Jul 13, 2008, at 8:48 AM, Nick Cox wrote:


I do not understand this to be a merging issue. You appear to have just
one dataset.
In Stata, -merge- requires two datasets.

Nor do I see why you think you need a dummy for every official.

My guess is that you have a problem for which -collapse- is the
solution.

However, you need to -reshape- first.

Here is a guess at an analogue to your problem.

. l

+--------------------------------------+
| Meet WhoL ScoreL WhoW ScoreW |
|--------------------------------------|
1. | 1 B 3 A 12 |
2. | 2 A 6 B 7 |
3. | 3 D 3 C 4 |
4. | 4 C 4 D 3 |
+--------------------------------------+

. reshape long Who Score, i(Meet) string
(note: j = L W)

Data wide -> long
------------------------------------------------------------------------
-----
Number of obs. 4 -> 8
Number of variables 5 -> 4
j variable (2 values) -> _j
xij variables:
WhoL WhoW -> Who
ScoreL ScoreW -> Score
------------------------------------------------------------------------
-----

. l

+-------------------------+
| Meet _j Who Score |
|-------------------------|
1. | 1 L B 3 |
2. | 1 W A 12 |
3. | 2 L A 6 |
4. | 2 W B 7 |
5. | 3 L D 3 |
|-------------------------|
6. | 3 W C 4 |
7. | 4 L C 4 |
8. | 4 W D 3 |
+-------------------------+

After that, you can -collapse- by -Who-.

Nick
[email protected]

Rufus Peabody

I'm doing an analysis of college football officiating and have a large
dataset. Each game played is an observation. There are 7 types of
officials, and I have an ID for each official. I have the 7 official
variables, but the problem is that officials are not confined
exclusively to one type---for example, one official might be "Referee"
one game and "Line Judge" another. What I did to alleviate this
problem was create dummies for each official (there are 596 in total).

Now, the major issue: I would like to somehow transform this so that
each official is an observation and I have mean(penalties),
mean(penalty yards), total games, etc. as variables. This would mean
there should be 596 total observations. Anybody have any suggestions
of how to tackle this problem?

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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