Statalist The Stata Listserver


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

Re: st: copy value within group


From   Ulrich Kohler <kohler@wz-berlin.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: copy value within group
Date   Mon, 23 Oct 2006 16:18:19 +0200

frakt@bu.edu wrote:
> Tim Wade suggested
>
> > . qui bysort id (x): replace x=x[1]
>
> Thanks Tim.  This is indeed better and it hadn't occured to me probably
> because I tend to not remember what order -sort- puts things in and so
> I try not to rely on the specific order (ascending or descending) if I
> can avoid it.  (I know I can just look it up or experiment, and I do
> when needed.)  Nevertheless, I think I will adopt this approach since
> it is one line long and clearer.

No need for look up here. The -bysort- command explicitely orders the variable 
according to id _and_ x. This is why the x is mentioned in the parentheses of 
the by-prefix.

Uli

-- 
kohler@wz-berlin.de
+49 (030) 25491-361
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index