Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Scott Merryman <scott.merryman@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Replace value for some observation with average values of some other observations? |
Date | Wed, 18 Jan 2012 06:27:02 -0600 |
sum outcome if id == 2 | id ==3replace outcome = r(mean) if id == 1 Scott On Wed, Jan 18, 2012 at 6:16 AM, Stata Chris <statachris@gmail.com> wrote: > Dear list members, > > Suppose I have a dataset with variables id and outcome. > Now for the observation with id=1 I want to replace the value of the > outcome by the average outcome values of the observations with id=2 > and id=3. > > I thought of > > replace outcome=mean(outcome[id==2],outcome[id==3]), but this does not > quite work. > > Would anyone know how to do this correctly? > > Thank you so much, > C * * 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/