Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Keepping observations that satisfy a concrete feature in the last period


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Keepping observations that satisfy a concrete feature in the last period
Date   Wed, 24 Apr 2013 13:05:07 +0100

The last value observed can be put in a variable

bysort id (time) : gen lastsize = size[_N]

so that you can always -keep- or -drop- dependent on that.

For a wider-ranging survey of basic technique in this territory, see

http://www.stata-journal.com/article.html?article=dm0055

Nick
njcoxstata@gmail.com

On 24 April 2013 12:55, Miguel Angel Duran <maduran@uma.es> wrote:

> I would like to analyze separately agents that have a particular feature, eg
> their size in the last period is large. But I don't know how to tell Stata
> that the criterion is the size in the last period. Will anyone please help
> me to find out how this can be done?
>
> To illustrate what I pretend, consider this dataset:
>
> time    id      size
> 1       100     29
> 1       200     26
> 2       100     33
> 2       200     34
> 3       100     43
> 3       200     44
> 3       300     45
>
> Althoug id=100 is larger in the first period than id=200, I would like to
> keep id=200 (because it is larger in time=3). In addition, I would like to
> keep id=300 (that just appear in time=3).
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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