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/