Statalist


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

Re: st: multiple observations


From   Ronan Conroy <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: multiple observations
Date   Tue, 9 Sep 2008 10:25:39 +0100

Replying on how to tag the last observation for each case,

On 8 Sep 2008, at 13:14, fjc fjc wrote:

You can also try:

gen newid = .
bysort id: replace newid = 1 if _n == _N
The problem is to make sure that the last observation for each id is really the last observation.

To be doubly sure, you need a variable that identifies the observation, then make sure that it too is sorted

bysort id (obsnumber) : replace newid=1 if _n == _N


Ronan Conroy
=================================

[email protected]
Royal College of Surgeons in Ireland
Epidemiology Department,
Beaux Lane House, Dublin 2, Ireland
+353 (0)1 402 2431
+353 (0)87 799 97 95
+353 (0)1 402 2764 (Fax - remember them?)
http://www.flickr.com/photos/ronanconroy/sets/72157601895416740/

P Before printing, think about the environment




*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index