Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: tricky calculation with dozens of variables


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: tricky calculation with dozens of variables
Date   Sun, 9 Oct 2005 08:00:12 -0400

You have the quotes wrong in referencing i. It should be `i', not 'i'. You will also need to generate total=0 to start.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- From: "Jia Xiangping" <jiajoseph@googlemail.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Sunday, October 09, 2005 5:04 AM
Subject: Re: st: tricky calculation with dozens of variables



Hi Svend,

It still doesn't work. I programed in this way(variables name are
different in my dataset, so I still use you example for convenience)

//calculated total
forvalues i=4(11)386{
local j='i'+4
replace total=total+var'i'*var'j'
}

Then Stata 8.2 informs me
'i' invalid name
r(198)

If I need to define i before run the ado above? Thanks

Joe
*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index