Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Assign highest value per group to all members of that group


From   Richard Goldstein <richgold@ix.netcom.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Assign highest value per group to all members of that group
Date   Fri, 04 Feb 2011 13:11:45 -0500

try this:

egen maxX=max(X), by(G)

Rich

On 2/4/11 12:56 PM, Owen Corrigan wrote:
> My data contains individual observations (taking a value 0-8 on indep
> variable X) divided into small unequal groups, where each group is
> uniquely identified by a grouping variable (G). I want to identify the
> highest value on X in each group uniquely identified by G and generate
> a new variable assigning that value to all members of that group. It
> should be a simple task, but standard data manipulation commands don't
> seem up to it, and I'm not versed in writing code or loops in Stata.
> 
> Any quick and simple solutions greatly appreciated.
> 
> Yours,
> O. Corrigan
> University of Dublin.
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index