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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Re: RE: Re: Fill in panel observations |

Date |
Sun, 29 Mar 2009 18:32:11 +0100 |

It's not in any sense a trick, even in Stata terms. It's just an analogue of what you used to number observations sequentially bys iis: g rater = _n Using _N not _n counts the total number of observations. Thinking in terms of _n and _N is a Stata fundamental. Nick n.j.cox@durham.ac.uk John Antonakis In fact, I had no missing data (and am aware that this can create problems).....so the initial solution of Martin was correct and "loyal" to the problem, though Nick's trick is also handy to know. On 29.03.2009 18:29, Martin Weiss wrote: > That is the thing about posts with example data in them. You can > answer the request based on the structure of the data that you observe > in the post. That means you assume that the poster knows best and gave > an accurate representative sample of his data. > > Or you think ahead and anticipate that there must be some kind of > problem in there that the poster does not regard as a problem, e.g. > missing values. But you run into a new problem then: We do not know > what John wants to happen if there are missing values. Maybe he still > wants the -egen, count()- solution even then? > > I chose the former attitude to the problem, but I recommend that John > pay close attention to Nick`s recommendation and implement them if he > feels they do what he wants... "Nick Cox" <n.j.cox@durham.ac.uk> >> There will be a difference between the results >> >> bys iis: egen total_rater = count(rater) >> >> and >> >> bys iis : gen total_rater = _N >> >> if -rater- is ever missing; but otherwise the latter is more direct and >> more efficient. >> >> Incidentally, once you known that data are sorted on -iis-, the second >> command can just start -by iis:-. >> >> Nick >> n.j.cox@durham.ac.uk >> >> Martin Weiss >> >> bys iis: g rater=_n >> bys iis: egen total_rater=count(rater) >> >> John Antonakis >> >>> I have multiple observations on leaders (iis) by raters, like this: >>> >>> iis sex age y rater total_rater >>> 1 0 43 5 1 5 >>> 1 0 43 9 2 5 >>> 1 0 43 3 3 5 >>> 1 0 43 6 4 5 >>> 1 0 43 6 5 5 >>> 2 1 46 9 1 7 >>> 2 1 46 7 2 7 >>> 2 1 46 9 3 7 >>> 2 1 46 6 4 7 >>> 2 1 46 7 5 7 >>> 2 1 46 2 6 7 >>> 2 1 46 8 7 7 >>> >>> At this time, the rater column and total_rater columns are blank. I >>> would like to fill them in such that: >>> >>> a. Under "Rater" I number each within the panel, starting with 1 and >>> going up to k raters (as I have done above). >>> b. The total number of k raters is included for each leader (as in the >> >>> total_rater column). >>> >>> Is there a quick way to do this? * * 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/

**References**:**st: check whether a variable has any missing values***From:*Jacob Wegelin <jacob.wegelin@gmail.com>

**st: Re: check whether a variable has any missing values***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: Fill in panel observations***From:*John Antonakis <John.Antonakis@unil.ch>

**st: Re: Fill in panel observations***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: Re: Fill in panel observations***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: Re: RE: Re: Fill in panel observations***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: Re: RE: Re: Fill in panel observations***From:*John Antonakis <John.Antonakis@unil.ch>

- Prev by Date:
**Re: st: RE: SSC Archive help files now available in HTML** - Next by Date:
**RE: st: cox regression alternatives** - Previous by thread:
**Re: st: Re: RE: Re: Fill in panel observations** - Next by thread:
**Re: st: Fill in panel observations** - Index(es):

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