Hello All --
Is there a way to save the mean in r() for each value of a 
variable?  More specifically, I want the mean for each 
different person contained within the variable 'name'.  My 
programming experience in Stata is quite limited so I'd 
appreciate any advice; the shrapnel from my attempt at coding 
is pasted below:
program mean_get 
	syntax [varlist] 
		foreach i of local varlist { 
			generate overall2 = 0
			by name, sort:  summarize `i', meanonly
			local 1 = r(mean)
			by name, sort:  replace overall2 = `1'
			}  
end 
When I run this, it returns the mean from the last value in 
'name' and uses it to replace all values of 'overall2'.  Any 
suggestions?
Many thanks...
Clint Thompson
*
*   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/