Statalist


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

st: RE: assign a mean/median a value to a new variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: assign a mean/median a value to a new variable
Date   Wed, 5 Nov 2008 20:59:00 -0000

You're correct. It does not work. Why do you think it should? Just
guessing at what you think the syntax might be is not a good strategy.  

summarize Y, meanonly 
gen X = r(mean) 

is one way to do it. 

Nick 
[email protected] 

Shuaizhang Feng

Suppose I have a data set that only contains one variable Y. and I want
to add a variable x that equals the mean (or median) of Y for all
observations. How do I do that?  Apparantly x=mean(Y) doesn't seem to
work. 


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