Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: SV: Calculate the mean of y if there are many similar x


From   P�r-Ola Bendahl <[email protected]>
To   <[email protected]>
Subject   st: SV: Calculate the mean of y if there are many similar x
Date   Fri, 18 Mar 2005 13:33:22 +0100

Hi,

bysort x:egen y_mean=mean(y)
sort x
drop if x==x[_n-1]

will do the job,

P�r-Ola Bendahl


> -----Ursprungligt meddelande-----
> Fr�n: [email protected]
> [mailto:[email protected]] F�r Eik Leong Swee
> Skickat: den 18 mars 2005 05:45
> Till: [email protected]
> �mne: st: Calculate the mean of y if there are many similar x
>
>
> Hello. I have a problem here trying to sort my data. I have 2
> variables y and x. Each one is of length 15000. However, y is
> unique but x is not i.e. for some values of y, there are more
> than one x. Specifically, there are 3573 unique values of x.
> I wish to take the mean of y for those x's that are the same,
> so that I end up only with a unique set of 3573 (y,x). I can
> either manually compute the mean 3573 times, or hopefully
> someone out there knows a command I can use. THANKS A LOT in advance!
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
*
*   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/



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