That should read
foreach v of varlist var1-var100 {
g m_`v'=(`v'[_n*2-1]+`v'[(_n+1)*2-2])/2 if _n<=50
}
of course.
On 7/12/05, austin nichols <[email protected]> wrote:
> If you _really_ want the means coded in the first fifty observations,
> and the last fifty observations to be missing, and you don't have
> Stata 9, or you happen not to want to use Kit's mata code, you could:
>
> foreach v of varlist var1-var100 {
> g m3=(`v'[_n*2-1]+`v'[(_n+1)*2-2])/2 if _n<=50
> }
*
* 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/