Thanks also for your help, Nick! However, I still have the same problem. The was a typo in the message, I had it in the code. I have changed the _N, but still get the error.
. tokenize `varlist'
. local i 1
. while "``i''" != "" {
2. qui by `id': gen double mean`i' = sum(``i'') / _n
3. qui by `id': replace mean`i' = mean`i'[_N]
4. qui by `id': gen double diff`i' = ``i'' - mean`i'
5. local newlist `newlist' mean`i' diff`i'
6.
. local i = `i' 1
7. }
if not found
r(111);
end of do-file
r(111);
Thanks,
Paula
_________________________________________________________
http://www.latinmail.com. Gratuito, latino y en espa�ol.
*
* 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/